C style

Carl Lowenstein cdl at mplvax.UUCP
Fri Nov 1 14:32:06 AEST 1985


In article <538 at ttrdc.UUCP> levy at ttrdc.UUCP (Daniel R. Levy) writes:
>In article <259 at 3comvax.UUCP>, mikes at 3comvax.UUCP (Mike Shannon) writes:
>>Sorry Scott, I don't buy it.  Your example isn't good enough:
>functions may be interdependent, share variables, etc, and the order of eval-
>uation may be important, or maybe the first checks are very quick and the
>latter ones are slow, making the order important to performance optimization
>if it is likely that one of the quick checks would fail.  The && operator
>doesn't GUARANTEE the chronological order of evaluation is going to be left
>to right, if you have a screwball compiler (though it most probably will be).

Kernighan & Ritchie, The C Programming Language, p. 190:

"Unlike &, && guarantees left-to-right evaluation; moreover the second
operand is not evaluated if the first operand is 0."

-- 
	carl lowenstein		marine physical lab	u.c. san diego
	{ihnp4|decvax|akgua|dcdwest|ucbvax}	!sdcsvax!mplvax!cdl



More information about the Comp.lang.c mailing list