the language states that a boolean expression stops its evaluation when the answer is known, so if you have to evaluate (A && B) and A is false, then B is not evaluated
it was working in the same way in C, There is a sequence point after the evaluation of the first element and if the answer is known, then the second part is not evaluated
this seems only relevant to a 3 condition statemen such as
if (a == 3 || b == 2 && c == 1)
but my question is about the order conditions are processed in statement such as if (a == 3 && b ==2)
or if (a == 3 || b == 2)
you're saying the conditions involving 'a' are always evaluated first because they are the first condition in the source code
yes a==3 will always be evaluated first for its truth value
with the &&, if it's false, b==2 won't be checked
with the ||, if it's true, b==2 won't be checked
Many languages have it. Know that Nick didn't want it in Pascal, so you have to watch out when you think it might be universally seen as a good thing.
Oops! Evidently Pascal does have it, I wonder if that was added at some point, I would swear there was a time (or was it another legit mainstream language) that it did not.
Order of evaluation of the operands of any C operator, including the order of evaluation of function arguments in a function-call expression, and the order of evaluation of the subexpressions within any expression is unspecified (except where noted below). The compiler will evaluate them in any order, and may choose another order when the same expression is evaluated again.
There is no concept of left-to-right or right-to-left evaluation in C
it is clear that there is no point in further evaluation if the conditions are ANDed and the first evaluated condition is false
so when does it -- Order of Evaluation (or lack of) -- apply?
it seems Order of Evaluation and "short circuiting" are two independent concepts
regardless of Order of Evalulation, it make no sense to evaluate the 2nd condition (in any order) if the first one evaluated is false and the 2nd condition is ANDed