-
Notifications
You must be signed in to change notification settings - Fork 22
else expression
Cameron Purdy edited this page Apr 6, 2020
·
3 revisions
The grounding “else” expression is a fairly new construct in programming languages; syntactically, it is similar to the “else” branch of a ternary expression:
a : b
The expression yields the result of the expression a. If the expression a arcs, then the expression yields the result of the expression b.
It is a compile-time error if expression a does not short-circuit. The expression short-circuits iff expression b short-circuits.
Definite assignment rules:
- The VAS before
ais the VAS before the expression. - The VAS before
bis the join of the VAS from each short-circuiting point ina. - The VAS after the expression is the join of the VAS after
aand the VAS afterb.
Note that the “else” operator groups to the right, which is different from most other binary operators:
ElseExpression:
TernaryExpression
TernaryExpression : Expression
That means that a : b : c is treated the same as a : (b : c).