comma operator

Bill Rust wjr at ftp.COM
Fri Aug 4 23:20:19 AEST 1989


|From article <3287 at ohstpy.mps.ohio-state.edu>, by SMITHJ at ohstpy.mps.ohio-state.edu:
|> In article <1351 at cbnewsl.ATT.COM>, mpl at cbnewsl.ATT.COM (michael.p.lindner) writes:
||| ***FLAME ON!***
||| Sigh.  RTFM!  The comma operator guarantees left to right evaluation,
|| and fprintf(...) and exit(...) ARE valid expressions in C.
||| sputter sputter - flame off.
|| 
|| Maybe I'm mistaken, but I'm sure that all the documentation I've read warns
|| that the *comma* operator ----does not----- guarantee evaluation in any order.
|| Specifically, the Microsoft 5.0 manual mentions this.
||

Sorry, but you are mistaken. Quoting MSC Language Ref p 130 v5.1 (5.0
is identical), "The sequential-evaluation operator evaluates its two
operands sequentially from left to right. There is a sequence point
after the first operand. The result of the operation has the same
value and type as the right operand. Each operand can be of any type.
 ...  The sequential-evaluation operator, also called the "comma
operator," is typically used to evaluate two or more expressions in
contexts where only one expression is allowed." In short, MS has it
right in their definition and, even though I have lots of experience
with MSC, I find it hard to believe that this point doesn't work
right.

Bill Rust (wjr at ftp.com)



More information about the Comp.lang.c mailing list