Skip to main content

Shortcut evaluation

· One min read
Guillaume Duhamel

We present a change in version 1.3.0 of the evaluation process of boolean operators and and or in test expression of the if instruction and expression.

Consider the following if instruction:

if a and b then
/* */
end

Before version 1.3.0, both expressions a and b were evaluated, meaning that if b is a failing expression, the evaluation fails even if a is false.

Since version 1.3.0, a and b is replaced by conditional expression:

if a then b else false

Equivalently, expression a or b is replaced by:

if a then true else b

Such that expression b is evaluated only when necessary.

Greedy evaluation

The previous greedy evaluation mechanism is still available with the greedy_and and greedy_or builtins.