nomenclature issue

P

Peter Nilsson

Keith Thompson said:
pete said:
Is this an expression:
(5)
?

N869
6.5 Expressions
[#1] 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.

I see two punctuators and an integer constant,
but no operators and no operand.
I don't know if "computation" means "evaluation".

The grammar clearly implies that
(5)
or just
5
is an expression. (A constant is a primary-expression, which is a
postfix-expression, which (skipping a few steps) is an expression.)

The wording of the definition in 6.5 just barely misses capturing the
obvious intent. (No, 5 is not an operand in this context; the word
"operand" is defined in 6.4.6 as "an entity on which an operator
acts", and there's no operator.)

It's probably worthwhile to fix the wording, but not to spend too much
time worrying about it.


What exactly is wrong with 6.5.1p5 in this case?
 
L

Leor Zolman

In other words, with exactly one exception (expression statements),
C statements aren't expressions.

C "statements" are _never_ "expressions". An "expression statement" is
an expression followed by a semicolon; the semicolon is not considered
part of the expression.
-leor

Leor Zolman
BD Software
(e-mail address removed)
www.bdsoft.com -- On-Site Training in C/C++, Java, Perl & Unix
C++ users: Download BD Software's free STL Error Message
Decryptor at www.bdsoft.com/tools/stlfilt.html
 
K

Keith Thompson

Peter Nilsson said:
What exactly is wrong with 6.5.1p5 in this case?

Nothing is wrong with 6.5.1p5 (the grammar that says a constant is a
primary-expression). The problem is that the definition of
"expression" in 6.5p1 doesn't properly reflect this.

I've started a new thread in comp.std.c, subject "Is 5 an expression?"
 
L

Lew Pitcher

Mantorok said:
But here is the problem with considering 4 to be an expression

Anexpression 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.

According to the standard

4 is a non-zero digit
which is a decimal constant
which is an integer constant (6.4.4.1)
which is a constant (6.4.4)
which is a primary expression (6.5.1.3)

So sayeth the standard



--
Lew Pitcher

Master Codewright and JOAT-in-training
Registered Linux User #112576 (http://counter.li.org/)
Slackware - Because I know what I'm doing.
 
K

Keith Thompson

Lew Pitcher said:
Mantorok Redgormor wrote: [...]
But here is the problem with considering 4 to be an expression
Anexpression 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.

According to the standard

4 is a non-zero digit
which is a decimal constant
which is an integer constant (6.4.4.1)
which is a constant (6.4.4)
which is a primary expression (6.5.1.3)

So sayeth the standard

So sayeth the grammar in the standard. (BTW, you have to follow
several several more steps to prove that a "primary expression" is an
"expression".) But the standard's definition of the term
"expression", in 6.5p1, sayeth that 4 is *not* an expression, because
it's not a sequence of operators and operands.

We all know that 4 is an expression, and that the authors of the
standard intended 4 to be an expression. The only real issue, I
think, is that the definition in 6.5p1 needs to be tightened up a bit.
And that's probably better discussed in comp.std.c; see the "Is 5 an
expression?" thread over there.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,772
Messages
2,569,593
Members
45,111
Latest member
KetoBurn
Top