Re: and then... (a curiosity)



Adam Beneschan wrote:

"and then" is not a function, however, and has none of these
properties.

To make "and" [and "or"] on two Booleans behave like the short-circuit
form would introduce a major inconsistency into the language.

In addition to the other reasons, there's the question of processor optimization. Although we have a sequential view of how code is executed, modern processors do all sorts of strange optimizations, such as speculative execution, that violate that sequential view. It's my understanding that the short-circuit forms can prevent such optimizations. Apparently, code that may evaluate only one of the 2 expressions can actually be slower than code that must evaluate both.

--
Jeff Carter
"If I could find a sheriff who so offends the citizens of Rock
Ridge that his very appearance would drive them out of town ...
but where would I find such a man? Why am I asking you?"
Blazing Saddles
37
.