Evaluating Conditional Expressions
- Conditions within parentheses are evaluated first.
- Within nested parentheses, evaluation proceeds from the least inclusive condition to the most inclusive condition.
- Arithmetic expressions.
- Simple-conditions in the following order:
- Relation
- Class
- Condition-name
- Switch-status
- Sign.
- Negated simple-conditions in the same order as item 2.
- Combined conditions, in the following order:
- AND
- OR.
- Negated combined conditions in the following order:
- AND
- OR.
- Consecutive operands at the same evaluation-order level are evaluated from left to right. However, the truth value of a combined condition can sometimes be determined without evaluating the truth value of all the component conditions.
The component conditions of a combined condition are evaluated from left to right. If the truth value of one condition is not affected by the evaluation of further elements of the combined condition, these elements are not evaluated. However, the truth value of the condition will always be the same (as if the condition had been evaluated in full), as described earlier in this paragraph.
Values are established for arithmetic expressions and functions if and when the conditions containing them are evaluated. Similarly, negated conditions are evaluated if and when it is necessary to evaluate the complex condition that they represent.
NOT A IS GREATER THAN B OR A + B IS EQUAL
TO C AND D IS POSITIVE
(NOT (A IS GREATER THAN B)) OR (((A+B) IS EQUAL
TO C) AND (D IS POSITIVE))
- (NOT (A IS GREATER THAN B)) is evaluated. If true, the rest of the condition is not evaluated, as the expression is true.
- (A+B) is evaluated, giving some intermediate result, x.
- (x IS EQUAL TO C) is evaluated. If false, the rest of the condition is not evaluated, as the expression is false.
- (D IS POSITIVE) is evaluated, giving the final truth value of the expression.