or expression - xtclang/xvm GitHub Wiki
The logical “or” expression is a well-known expression form:
a || b
Additionally, an exclusive-or (xor) expression with the ^^ operator shares the same operator precedence level:
a ^^ b
The type of the expressions a and b must both be Boolean. The implicit type of the expression is Boolean.
For the || operator: If the expression a yields True, then the expression yields True, and the expression for b is not evaluated[1]. Otherwise, if the expression a yields False, then the expression yields the result of the expression b.
For the ^^ operator: Both the expression a and b are evaluated. If the two yielded values are the same, then the expression yields False; otherwise the expression yields True.
The expression short-circuits if either expression a or b short-circuits.
Definite assignment rules for the || operator:
- The VAS before
ais the VAS before the expression. - The VAS before
bis the VASF aftera. - The VAS after the expression is the join of the VAST after
aand the VAS afterb. - The VAST after the expression is the join of the VAST after
aand the VAST afterb. - The VASF after the expression is the VASF after
b.
Definite assignment rules for the ^^ operator:
- The VAS before
ais the VAS before the expression. - The VAS before
bis the VAS aftera. - The VAS after the expression is the VAS after
b.
The OrExpression groups to the left, so a || b || c is treated as (a || b) || c.
OrExpression:
AndExpression
OrExpression || AndExpression
OrExpression ^^ AndExpression
This is often referred to as "short-circuit logic", but that term is not used here, in order to avoid confusion with the Ecstasy concept of short-circuiting expressions.↩