mike@whuxl.UUCP (BALDWIN) (10/30/85)
> 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
levy@ttrdc.UUCP (Daniel R. Levy) (10/31/85)
In article <757@whuxl.UUCP>, mike@whuxl.UUCP (BALDWIN) writes: >> 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] (that's me) > >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 I stand corrected. -- ------------------------------- Disclaimer: The views contained herein are | dan levy | yvel nad | my own and are not at all those of my em- | an engihacker @ | ployer or the administrator of any computer | at&t computer systems division | upon which I may hack. | skokie, illinois | -------------------------------- Path: ..!ihnp4!ttrdc!levy