Short-circuit evaluation

new topic     » topic index » view thread      » older message » newer message

Rob:
I know, it is seldom used and impractical, but have you thought about
extending short-circuit evaluation to the operations I mention below? I was
thinking about this only regarding educational purposes: you know there are
16 possible binary Boolean operations with 2 operands. Some comparison
operations can be used in a Boolean context. For example, XOR is not needed
at the variable-level because it may be substituted by !=. The operations I
was thinking of are:

if (a > b) >= (x = z) then ... If a > b is true, then there is no need to
evaluate x = z.

if (c <= u) > ( d > g) then... If c <= u is false, then there is no need to
evaluate d > g

and similarly with <= and <.
These operations, when used with Boolean operands, might be thought about as
"implication", etc.

= and != cannot be short-circuited.

AFAIK, C doesn't use this little trick.
Regards.

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu