Control flow
L4 has no statements, only expressions, so choosing between results is done with expressions that give a value.
IF and BRANCH choose by conditions; CONSIDER chooses by the shape of a value. In each, every outcome must have the same type.
Pages
- IF:
IF … THEN … ELSE, one condition and two outcomes - BRANCH: several conditions, tried from top to bottom, with
OTHERWISE - CONSIDER: pattern matching with
WHEN … THENandOTHERWISE, and the check for missing branches
A function can also be written as several clauses, one per case, which means the same as a CONSIDER.
Conditions are combined with AND, OR, NOT, IMPLIES and UNLESS.
The Foundation course, module 3 teaches these step by step.