comma operator

Steve kelley smk at dip.eecs.umich.edu
Sat Aug 5 00:50:43 AEST 1989


In article <3287 at ohstpy.mps.ohio-state.edu> SMITHJ at ohstpy.mps.ohio-state.edu writes:
>In article <1351 at cbnewsl.ATT.COM>, mpl at cbnewsl.ATT.COM (michael.p.lindner) writes:
>> Sigh.  RTFM!  The comma operator guarantees left to right evaluation,
>
>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.
>
>/* Jeffery G. Smith, BS-RHIT (AKA Doc. Insomnia, WMHD-FM)       *

I'm afraid you are mistaken.  In particular, the Microsoft C Language
Reference version 5.0 specifically mentions: "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," [sic] is typically used to evaluate two or more expressions
in contexts where only one expression is allowed."

Steve Kelley



More information about the Comp.lang.c mailing list