[net.lang.c] Evaluation order

chris@umcp-cs.UUCP (Chris Torek) (11/01/85)

In article <538@ttrdc.UUCP> levy@ttrdc.UUCP (Daniel R. Levy) writes:

> The && operator doesn't GUARANTEE the chronological order of evaluation
> is going to be left to right,

No.  && and || are guaranteed to evaluate the left hand side of
the expression, and if the result is false or true (respectively)
stop, otherwise evaluate the right hand side.  (These are `McCarthy'
or short-circuiting expressions.)  This is why

	if (p == NULL || *p == 0)

is guaranteed not to crash even on a machine where *(type *)NULL
will.

> if you have a screwball compiler (though it most probably will be).

If you change that to `a broken compiler' I will agree.
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 4251)
UUCP:	seismo!umcp-cs!chris
CSNet:	chris@umcp-cs		ARPA:	chris@mimsy.umd.edu