Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10.1 6/24/83; site umcp-cs.UUCP
Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!genrad!panda!talcott!harvard!seismo!lll-crg!gymble!umcp-cs!chris
From: chris@umcp-cs.UUCP (Chris Torek)
Newsgroups: net.lang.c
Subject: Evaluation order (`&&') (was: Re: C style)
Message-ID: <2041@umcp-cs.UUCP>
Date: Thu, 31-Oct-85 19:33:37 EST
Article-I.D.: umcp-cs.2041
Posted: Thu Oct 31 19:33:37 1985
Date-Received: Sat, 2-Nov-85 07:49:15 EST
References: <1556@brl-tgr> <2600023@ccvaxa> <259@3comvax.UUCP> <538@ttrdc.UUCP>
Organization: U of Maryland, Computer Science Dept., College Park, MD
Lines: 22

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