Peter Pichler said:
"The" problem? What problem?
I cannot see a problem. 4 is an operand. An expression does not
necessarily need operators:
6.5.1 Primary expressions
1 primary-expression:
identifier
constant
string-literal
( expression )
Semantics
2 An identifier is a primary expression, provided it has been declared as
designating an
object (in which case it is an lvalue) or a function (in which case it is a
function
designator).76)
3 A constant is a primary expression. Its type depends on its form and
value, as detailed in
6.4.4.
Peter
Yeah but we can't consider primary expressions as
expressions can we?
The definition given for "expressions" is:
"An expression is a sequence of operators and
operands that specifies computation of a value,
or that designates an object or a function, or
that generates side effects, or that
performs a combination thereof."
given something like:
func(foo, 4);
we can't say that func takes two arguments
each of which is an expression
I would like to generalize it and say that
but I don't think it is correct given the
definition of expression.
We would have to say "foo" is an expression
and 4 is a primary expression, I think.
4 alone is not a sequence of operators and operands
(both are plural and imply more than one).
it doesn't specify computation of a value
since the value is a constant, no computation
is performed. it doesn't designate an object
or a function or give side-effects.
I'm only asking this because of the term
"value of the expression"
if 4 does not fall under the definition of expression
but instead the definition of primary expression
and we do the following:
int func(int);
...
func(4);
...
int func(int a)
{
...
do we say "a" has the value of the primary expression
"4"? though I don't see that term used in the standard.
I just see "value of the expression".