Guards¶
Syntax¶
Description¶
A guard is condition : expression inside a dfn. If condition evaluates to 1 (true), expression is returned immediately and no further statements execute.
Multiple guards are checked top to bottom. The first true guard wins. If no guard fires, the last expression in the body is the result.
Examples¶
Absolute value:
Condition requirements¶
The condition must produce a scalar boolean (0 or 1).
Evaluation order¶
Guards are evaluated in order from top to bottom. Once a guard fires, execution stops. Statements before a guard execute normally and can set local variables.