Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84 exptools; site whuxl.UUCP Path: utzoo!watmath!clyde!cbosgd!ihnp4!houxm!whuxl!mike From: mike@whuxl.UUCP (BALDWIN) Newsgroups: net.lang.c Subject: && and || *are* left to right Message-ID: <757@whuxl.UUCP> Date: Wed, 30-Oct-85 13:34:09 EST Article-I.D.: whuxl.757 Posted: Wed Oct 30 13:34:09 1985 Date-Received: Sat, 2-Nov-85 01:31:42 EST References: <1556@brl-tgr> <2600023@ccvaxa> <259@3comvax.UUCP> <538@ttrdc.UUCP> Organization: AT&T Bell Laboratories, Whippany Lines: 17 > 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). > [dan levy] I have to disagree with this. && and || are guaranteed to be left to right just as much as (1 && 1) is guaranteed to return true. This is a very important feature of C and makes tests like if (x != NULL && strcmp(x, "foo")) reasonable. If there are compilers out there that don't do && and || left to right, then they are broken. I'm not going to rewrite conditionals like that example (as nested ifs!) to accomodate *broken* compilers! In C, && and || ARE GUARANTEED to be evaluated left to right!! -- Michael Baldwin {at&t}!whuxl!mike