Boolean expressions

A Boolean expression has typeBooleanwhich has two values,trueandfalse.

Conditional expressions

Aconditional expressionhas the formif c then t else f,wherecis an expression of typeBoolean,andtandfare expressions of any type, buttandfmust have the same type.

Evaluation of conditional expressions is non-strict. The evaluation semantics ofif c then t else fare:

  • The conditioncis always evaluated.
  • Ifcevaluates totrue,the expressiontis evaluated andfremains unevaluated. The whole expression reduces to the value oft.
  • Ifcevaluates tofalse,the expressionfis evaluated andtremains unevaluated. The whole expression reduces to the value off.

The keywordsif,then,andelseeach introduce ablockas follows:

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

Boolean conjunction and disjunction

ABoolean conjunction expressionis aBooleanexpression of the forma && bwhereaandbareBooleanexpressions. Note that {&&} is not a function, but built-in syntax.

The evaluation semantics ofa && bare equivalent toif a then b else false.

ABoolean disjunction expressionis aBooleanexpression of the forma || bwhereaandbareBooleanexpressions. Note that {||} is not a function, but built-in syntax.

The evaluation semantics ofa || bare equivalent toif a then true else b.