2010/9/16 David Kastrup <firstname.lastname@example.org>
> In the view point of the parser, the logical operator 'and' has
> higher priority than 'or', but, for programmers, a ternary operatorWhy?
> must have lower priority than logical operator.
Because, the first operand of a ternary operator is a conditional _expression_. In a conditional _expression_, we want to use logical operators frequently, and unnecessary parenthesis are unwelcome.
And, the second operand of a ternary operator (which is between ? :, then/else, and/or etc.) is an independent _expression_, so if there is an operator which priority is lower than a ternary operator, it is very confusing. For example, and if a ternary operator is ? :, and its priority is equal to 'and' and higher than 'or', how to process following code.
x = A ? B or C : D