comma operator

Roemer Lievaart roemer at cs.vu.nl
Sat Aug 5 10:21:12 AEST 1989


I wrote:

>> I often write:
>> 
>> 	if (something_goes(wrong) )
>> 		fprintf(stderr, "%s: I give up!\n", argv[0] ) ,
>> 		exit(2) ;
>> 
>> Of course it's no better than using { ; }, but it's not worse either.

skilbane at zaphod.axion.bt.co.uk (Steven Kilbane) wrote

>Personally, I think it is worse that {;}. If you have something of the form
>	x = Expr1 , Expr2;
>then Expr2 will be assigned to x, rather than Expr1. If you rewrite them as
>	x = Expr1,
>	    Expr2;
>you're relying on (a) the indentation and (b) being very careful, to notice you
>have a comma instead of a semicolon. Inserting extra code might be nasty:
>	x= Expr1,
>	   Expr3;
>	   Expr2;

>*BOOM*...

What BOOM?
I gave a very specific example of where I use the comma-operator, where
it is not better or worse than using { ; }.

You come up with very, very different examples. Situations where I maybe would
never dream of using the comma operator. I never said I always use the comma
operator instead of { ; }, did I?
Sorry, but this is no reason for you to say "BOOM"! :-)

*BOOM* yourself.... ;-)

Regards,
	Roemer.
____________________________________________________________________________
Roemer B. Lievaart | "We would have killed him totally, were it not that an
Amsterdam, Holland | unexplicable fear made our heart stink into our boots
Europe, Earth.     | and we slunk off, and so I stand before you... How well
roemer at cs.vu.nl    | put, but nobody listens..."  -- Alfred Jarry's "Ubu Roi"

Or, to quote somenody (dunno who anymore):
I like the comma operator. I seldom use it, but I like it.



More information about the Comp.lang.c mailing list