tinman wrote:
Short circuit evaluation is a good thing. It means you don't need to evaluate both sides of a logical expression to get the result. Therefore if you have a simple comparison logically combined with an evil complex one, you're best putting the simple one on the left because it may mean you can avoid carrying out the right hand side thus saving you time.
For some background look
here.
I see it a little differently. The most important thing is to know, whether it happens or not unconditionally, or whether it can be controlled by a compiler switch (as in good old Turbo Pascal). Many compilers activate it in in higher optimisation levels only.
In the time of simple CPUs it was a classical time/space trade off: querying the boolean intermediate result and jumping out of the comparison chain, if the result can't depend on terms to follow, adds some opcodes and saves some time. In time of more advanced CPUs jumping flushed the prefetch queues, so it was not paying off always for short jumps (therefore ARM conditional execution). Now with branch prediction and caches it again may pay off, but its difficult to judge without benchmark.
Summary: Short circuiting saves execution time, if there are MANY terms or if some of the terms are time-consuming functions. It leads to grey hairs, if one of the functions has a side effect leading to sporadic errors. Even if not supported by the compiler, it can be substituted by explicit coding.