Mail Archives: djgpp/1997/08/07/11:49:17
In article <5sbb1h$kvr$1 AT newton DOT pacific DOT net DOT sg> you wrote:
> Is it safe to assume that the expression
> if(first_function()==OK && second_function()==OK &&
> third_function()==OK) return(OK);
> will be evaluated from left to right?
In contrast to the other answer I just had to see in the newsgroup:
*Yes*, this behaviour is even guaranteed by the ANSI C Standard,
and it was like that even before the Standard was written.
The so called 'short-circuiting' of logical expressions is what
requires the fixed order of evaluation of terms here:
if first_function() did *not* return 'OK', then none
of the other functions need to be called: the result of
the expression is 'false' anyway. So they won't be called.
HBB
- Raw text -