On 2013-01-19, Rupert Swarbrick <rswarbrick at gmail.com> wrote:
> Except that people expect "if" to short-circuit. That is
>
> if x>0 then sqrt(x) else error("aargh");
>
> shouldn't cause an error when x is positive... Similarly, what if one
> branch was a long computation? (Such as a complicated integral!)
Sure, that's a sensible default, but the problem at hand is that there
is no way to force it to be something different. The only way I can
think of is something like: apply ("if", [x > 0, foo, true, bar]);
where foo and bar are the stuff on the branches.
On a bit of a tangent -- a proposal was floated a while ago to make
"and", "or" and "not" simplifying commutative operators, and create new
ones "and_then", "or_else" as short-circuit operators. Makes sense to
me, and it probably wouldn't really be a lot of work.
best,
Robert Dodier