2.6. Operator precedence
Higher rows bind more tightly.
Precedence | Operators and forms | Associativity |
|---|---|---|
1000 |
| atomic |
95 |
call | left, chaining |
90 |
postfix | postfix |
80 |
| prefix |
70 |
| left |
60 |
| left |
40 |
| non-associative |
30 |
eager | left |
20 |
eager | left |
15 |
| right |
10 |
| compound forms right-associate |
Because if sits at precedence 20, an if used as an operand of a comparison or an arithmetic
operator needs parentheses: write (if c then 1 else 2) == y. Parenthesise freely when mixing
comparison, type-test, implication, and assignment forms.