SWITCH Expression
SWITCH selects one result from multiple cases.
Syntax
ACE resolves input exactly once. It then resolves case expressions in order until it finds the first match. The matching result is selected; if no case matches, the final default value is selected.
After resolution, ACE first attempts numeric equality (std::stod on both values). If numeric conversion is not possible, it falls back to exact string equality.
Example
Result:
Evaluation behavior
SWITCH is lazy for result branches: only the selected result (or the default when no case matches) is resolved. Non-selected result branches are not evaluated, so a CMD{...} that exists only in an unselected result branch is not executed.
Case expressions are not result branches. They are resolved as ACE tests them in order. A side-effecting expression placed in the switch input or in a case expression can therefore run when that input/case is evaluated.
An empty selected result is normalized to 0. A switch input that contains a CMD or another expression is still evaluated only once.