The branches of if-then-else expressions are not lazily evaluated.
For example, the following program:
fun (w: Writer)
if true then w.write("true\n")
else w.write("false\n")
…will write both "true" and "false" to the file.
This renders if-then-else unusable in many contexts, making algorithms difficult to write as conditionals need to be expressed using match expressions.
Is this something we want to fix? If-then-else expressions will probably need to desugar directly to match expressions instead of the ite function, since the invocation of a function necessitates eager evaluation.
A related problem is that boolean operators should short-circuit; they currently do not.
The branches of if-then-else expressions are not lazily evaluated.
For example, the following program:
…will write both "true" and "false" to the file.
This renders if-then-else unusable in many contexts, making algorithms difficult to write as conditionals need to be expressed using match expressions.
Is this something we want to fix? If-then-else expressions will probably need to desugar directly to match expressions instead of the
ite
function, since the invocation of a function necessitates eager evaluation.A related problem is that boolean operators should short-circuit; they currently do not.