From https://en.wikipedia.org/wiki/Short-circuit_evaluation is the
following paragraph [some special symbols don't jive with a remark, but
the other remarks are the point I want to highlight]:
The use of short-circuit operators has been criticized as problematic:
The conditional connectives — "cand" and "cor" for short — are ...
less innocent than they might seem at first sight. For instance, cor
does not distribute over cand: compare
(A cand B) cor C with (A cor C) cand (B cor C);
in the case ¬A ∧ C , the second expression requires B to be
defined, the first one does not. Because the conditional connectives
thus complicate the formal reasoning about programs, they are better
avoided.
— Edsger W. Dijkstra[1]
Ken was very fond of generalized identities if I recall correctly. That
is why "and" and "or" generalized to lcm and gcd so nicely. I am not
sure I have decided how I feel about adding short circuit logicals, but
I would at least encourage using something other than "and." so that the
short circuit would be clearer. Perhaps "cand." But doing this in the
context of control words seems a far better place than, say, using a fit
conjunction.
On 11/6/2017 2:58 PM, Henry Rich wrote:
Using ^: is a clever idea. But it makes heavy work of a simple and
useful case. If I want the equivalent of
if. cheapverb y and. expensiveverb y do.
end.
I have these options:
if. cheapverb y do. if. expensiveverb y do.
end. end.
if. cheapverb y do. expensiveverb y else. 0 end. do.
end.
if. (expensiveverb@[^:] cheapverb) y do.
end.
I think it makes a pretty good case for and. .
Henry Rich
On 11/6/2017 1:55 PM, Raul Miller wrote:
Probability is extremely low, since the parser does not hand control
to the verb until after both nouns have been computed. You can even
write code which abuses this (though that tends to be hard to
understand so few people like that sort of thing - but trying to
forbid foolish code at the language level tend to cripple things.)
^: on the other hand, puts control of this in the hands of the
programmer (its argument is two verbs and the right verb can control
whether he left verb does anything).
Thanks,
---
This email has been checked for viruses by AVG.
http://www.avg.com
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm