S
Steven T. Hatton
I'm trying to improve my formal understanding of C++. One significant part
of that effort involves clarifying my understanding of the vocabulary used
to describe the language.
This is from the C++ Standard:
"[Note: Clause 5 defines the syntax, order of evaluation, and meaning of
expressions. An expression is a sequence of operators and operands that
specifies a computation. An expression can result in a value and
can cause side effects. ...]"
"...sequence of operators and operands that specifies a computation...".
That means to me that an expression can be "executed". I am purposely
avoiding the term "evaluate" because that has connotations which I am not
sure apply to all expressions. Nonetheless, the notion of a computation
signifies to me that some kind of predetermined state change takes place at
the time the flow of control reaches the point in the compiled program
corresponding to the /expression/ appearing in the source code. So my
first question is:
How might we formulate a definition of "computation" which communicates the
intended meaning in the above quoted excerpt?
My second question involves the exact meaning of "An expression can result
in a value...". The concept of 'resulting in a value' suggests there is
some storage location holding said value at the instant at which the
execution ("evaluation" probably applies here) of the expression is
complete. I note that the Standard does not specifically state that an
expression can /return/ a value. It seems to me that the resulting value
of a function returning a type other than void will be the value returned.
But what about values assigned to non-const parameters passed by reference?
Are these to be considered side effects, resulting values, or both?
In C++ parlance, is the value resulting from `int x, y;/*...*/ x + y;'
considered a "return value"? Is there ever an instance in which
the 'resulting value' of an expression cannot properly be called
its 'return value'?
of that effort involves clarifying my understanding of the vocabulary used
to describe the language.
This is from the C++ Standard:
"[Note: Clause 5 defines the syntax, order of evaluation, and meaning of
expressions. An expression is a sequence of operators and operands that
specifies a computation. An expression can result in a value and
can cause side effects. ...]"
"...sequence of operators and operands that specifies a computation...".
That means to me that an expression can be "executed". I am purposely
avoiding the term "evaluate" because that has connotations which I am not
sure apply to all expressions. Nonetheless, the notion of a computation
signifies to me that some kind of predetermined state change takes place at
the time the flow of control reaches the point in the compiled program
corresponding to the /expression/ appearing in the source code. So my
first question is:
How might we formulate a definition of "computation" which communicates the
intended meaning in the above quoted excerpt?
My second question involves the exact meaning of "An expression can result
in a value...". The concept of 'resulting in a value' suggests there is
some storage location holding said value at the instant at which the
execution ("evaluation" probably applies here) of the expression is
complete. I note that the Standard does not specifically state that an
expression can /return/ a value. It seems to me that the resulting value
of a function returning a type other than void will be the value returned.
But what about values assigned to non-const parameters passed by reference?
Are these to be considered side effects, resulting values, or both?
In C++ parlance, is the value resulting from `int x, y;/*...*/ x + y;'
considered a "return value"? Is there ever an instance in which
the 'resulting value' of an expression cannot properly be called
its 'return value'?