Re: Concept of Statements and Expressions



void * clvrmnky() wrote:

pete wrote:
void * clvrmnky() wrote:
Keith Thompson wrote:
"Vladimir Oka" <novine@xxxxxxxxxxxxxxx> writes:

6.5p1 Expressions
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. [...]
This definition is actually inaccurate. For example,
42
is clearly an expression,
but it contains no operators and therefore no operands.
(No, there's no implicit invisible operator.)

Not really.

Right. My reasoning is that "42" is an rvalue expression
(where an expression is defined as
"one or more terms and zero or more operators")
consisting of a single term which is an integer constant.

You just made that up.

J'Accuse!

Made what up, specifically? The definition of an expression?

Yes.

Well
/someone/ made it up, but it sure wasn't me! I (unfortunately) do not
have the real Standard in front of me,
and find it painfully obtuse when I do.
I mostly make do with the brief discussion here:
<http://www-ccs.ucsd.edu/c/express.html>

Is there something wrong
with this general discussion of C expressions?

Not too bad.
A few nits here and there:

"A function-designator subcontext designates a function.
Hence, its expression has a function type.
You create a function-designator subcontext
wherever you need to call a function or determine its address."

You can use an expression of function type to make a function call,
but a pointer to a function expression,
which itself has an object type,
is really what's needed to make a function call.
If a function call is made with an expression of function type,
then that expression is converted to a pointer first.

There's some original vocabulary in there.
Later down this post, where you use the phrase "a class conversion",
I assume it means the same thing as "a type conversion",
or what I would just refer to as "a conversion".

The standard says:
What is sometimes called ??rvalue??
is in this International Standard
described as the ??value of an expression??.

Now, in this context is the rvalue expression dropped via a class
conversion to result in a void expression?

There is no context provided. 42 is just 42.
The expression statement
42;
is executed and evaluated as
(void)42;

Isn't this, then, an rvalue subcontext where an rvalue expression is
converted to a void expression?

The classes of subcontext are not familiar to me
and I believe they are irrelevant
to the issue of expression statement evaluation.

N869
6.8.3 Expression and null statements
Semantics
[#2] The expression in an expression statement is evaluated
as a void expression for its side effects.

Which is sort of where I ended up, along a different path.
Close enough
for me if I read the code as a parser (and not a lawyer).

--
pete
.



Relevant Pages

  • Re: gcc knows about malloc()
    ... If a correct prototype is visible, this expression (after the implicit ... actual conversion and simply yields the same pointer-to-function ... this value to type void *. ...
    (comp.lang.c)
  • Re: srand(time(NULL))
    ... conversion of void * to whatever_type * is implicit). ... you should cast it to void*. ...
    (comp.lang.c)
  • Re: cast to void *
    ... When else is implicit conversion to 'void *' done, ... Except that conversion between void* and struct tm is a constraint ...
    (comp.lang.c)
  • Re: [PATCH 1/2] irq_flags_t: intro and core annotations
    ... * irq_flags_t allows conversion to struct instead of typedef without flag day. ... -static inline void native_restore_fl ...
    (Linux-Kernel)
  • Re: where is _ATL_SIMPLEMAPENTRY defined?
    ... As far as I can see, you still use pointer of function type, other than ... typedef void; ... // pointer to a testfunc ...
    (microsoft.public.vc.language)

Loading