mlaufer@bbncct.ARPA (Michael Laufer) (11/01/85)
Wait just one minute there. Dan Levy (..!ihnp4!ttrdc!levy) writes : >>Scott's example done the RIGHT (i.e. my :-)) way: >> for(i = 0; i < 100; i++) { >> if(f1(x) == OK && >> f2(x) == OK && >> f3(x) == OK && >> f4(x) == OK && >> f5(x) == OK ) { >> result[i] = 0; >> } >> else { >> result[i] = function6(x); >> } >> } >.......... 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). I hope this is not the case or I know a lot of code that will self destruct. In Harbison & Steele _A_C_Reference_Manual_ on page 181 : ....the logical operator '&&' guarantees left-to-right conditional evaluation. Any compilers that do not work this way cannot really call themselves 'C' compilers. What does the ANSI standard say about this? Michael Laufer mlaufer@bbn-unix.arpa
gwyn@BRL.ARPA (VLD/VMB) (11/01/85)
You don't have to check what X3J11 says; && and || were specifically designed to do "short-circuit" evaluation. I don't know what Dan was thinking of (Fortran or Pascal, perhaps; definitely not C).