At 13:41 -0800 03/03/31, Dave Long wrote:
Norm thinks about short-circuit operators in:
<http://www.cap-lore.com/Software/McDijk.html>
 McCarthy is credited with observing that in a programming language it
 is useful to require that a boolean operator between two predicate
 expressions not evaluate the second operand if the operator result is
 determined by the value of the first. Thus the C expression "(p && p->
 field)" is safe even when the pointer p is NULL, for then the
 indeterminate side effects of fetching the field are suppressed.

and among other things, comes up with: (p && (a, 1) || (b, 0)) as an expression encoding an if-then-else.

However, given a short-circuit NAND operator,
we wouldn't need both AND and OR.  Using the
Schaeffer stroke, |, for NAND, and taking it
to be a short-circuit operator (assuming the
commands implicitly succeed), we recover the
Algol68 brief notation:
        (p|a|b)
as a shortcut for:
        if p then a else b fi

Seems like a pun that requires knowledge of both Iriquois and Punjabi. I had trouble swapping both idea sets in at once. I think that if | is nand and is left associative then the boolean value of 'a' determines whether 'b' is executed. If right associative then neither a nor b is executed when p is false. It is scary that it almost works.

By the way after years of withdrawal symptoms there is a new Algol68 compiler!
See <http://www.xs4all.nl/~jmvdveer>.

-Dave


--
Norman Hardy  <http://cap-lore.com/>



Reply via email to