Re: and then... (a curiosity)
- From: "Jeffrey R. Carter" <spam.jrcarter.not@xxxxxxxxxxxx>
- Date: Sat, 30 Aug 2008 01:06:34 GMT
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
.
- References:
- and then... (a curiosity)
- From: mockturtle
- Re: and then... (a curiosity)
- From: Adam Beneschan
- and then... (a curiosity)
- Prev by Date: Re: Possible compiler bug with this simple program
- Next by Date: Very confused by Ada tasking, can not explain the execution outcome.
- Previous by thread: Re: and then... (a curiosity)
- Next by thread: Re: and then... (a curiosity)
- Index(es):