comma operator

David Goodenough dg at lakart.UUCP
Tue Aug 8 05:42:59 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.

In that case, MS C 5.0 is broken.

if I say:

	int a;

	a = (blurfl(), stug(), zorch());

and get _ANY_ other order of evaluation than blurfl() first, then stug(),
and finally zorch(), then I'm gonna deep six that compiler. The confusion
_MAY_ be arising due to the overloading of the comma operator: as a separator
in expressions it _DOES_ guarantee l->r order of eval, when separating
arguments to a function - as in:

	a = zap ( blurfl(), stug(), zorch() );

it definitely guarantees _NOTHING_.
-- 
	dg at lakart.UUCP - David Goodenough		+---+
						IHS	| +-+-+
	....... !harvard!xait!lakart!dg			+-+-+ |
AKA:	dg%lakart.uucp at xait.xerox.com		  	  +---+



More information about the Comp.lang.c mailing list