Boolean expressions

A Boolean expression has type Boolean which has two values, true and false.

Conditional expressions

A conditional expression has the form if c then t else f, where c is an expression of type Boolean, and t and f are expressions of any type, but t and f must have the same type.

Evaluation of conditional expressions is non-strict. The evaluation semantics of if c then t else f are:

  • The condition c is always evaluated.
  • If c evaluates to true, the expression t is evaluated and f remains unevaluated. The whole expression reduces to the value of t.
  • If c evaluates to false, the expression f is evaluated and t remains unevaluated. The whole expression reduces to the value of f.

The keywords if, then, and else each introduce a block as follows:

if
    true
  then
    "codeblock here"
  else
    "another codeblock"

Boolean conjunction and disjunction

A Boolean conjunction expression is a Boolean expression of the form a && b where a and b are Boolean expressions. Note that {&&} is not a function, but built-in syntax.

The evaluation semantics of a && b are equivalent to if a then b else false.

A Boolean disjunction expression is a Boolean expression of the form a || b where a and b are Boolean expressions. Note that {||} is not a function, but built-in syntax.

The evaluation semantics of a || b are equivalent to if a then true else b.