Re: comma operator



Richard Heathfield <rjh@xxxxxxxxxxxxxxx> writes:
Keith Thompson said:
luserXtrog <mijoryx@xxxxxxxxx> writes:
[...]
I find it easier to think of the comma as a semicolon without
a period. It terminates the expression without terminating the
statement.

Ah, but it doesn't terminate the expression; it only terminates a
subexpression.

Yes, it does. 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". A comma operator always terminates such a
sequence.

You're right, of course. (The standard's definition of "expression"
is broken, but that's a separate point.)

Incidentally, that's true only because the comma operator has a lower
precedence than any other operator.

--
Keith Thompson (The_Other_Keith) kst-u@xxxxxxx <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
.



Relevant Pages

  • Re: comma operator
    ... It terminates the expression without terminating the ... subexpression. ... An expression is "a sequence of operators and operands ... that's true only because the comma operator has a lower ...
    (comp.lang.c)
  • Re: comma operator
    ... the comma operator always terminates an ... expression - as do all binary operators. ... The comma operator is rarely useful! ...
    (comp.lang.c)
  • Re: comma operator
    ... but it doesn't terminate the expression; it only terminates ... that [the comma operator always terminates an ... true for unary operators, however. ... finger pointing at someone else, there's three pointing back at you. ...
    (comp.lang.c)
  • Re: comma operator
    ... It terminates the expression without terminating the ... subexpression. ... An expression is "a sequence of operators and operands ... A comma operator always terminates such a ...
    (comp.lang.c)
  • Re: comma operator
    ... the comma operator always terminates an ... expression - as do all binary operators. ... The comma operator is rarely useful! ...
    (comp.lang.c)