Conditional (cnd)

A Conditional (cnd) has a clause Compound Expression (compoundexpr), a then Compound Expression, and an else Compound Expression. If the clause evaluates to nil, the Conditional evaluates to the else Compound Expression. Otherwise it evaluates to the then Compound Expression.

A Singular Expression (expr) can be a Conditional.

cnd:

_images/cnd.png
cnd ::= 'if' compoundexpr 'then' compoundexpr 'else' compoundexpr 'end'

References:

Examples

A Conditional evaluating to the string “blub”:

if nil then "bla" else "blub" end

A Conditional checking if an ID x has converged returning it if true and improving it if nil:

if has-converged( state: x )
then
  x
else
  improve( state: x )
end