Laurel User Guide

2.6. Operator precedence🔗

Higher rows bind more tightly.

Precedence

Operators and forms

Associativity

1000

{ ... }, { ... } label

atomic

95

call f(...), field x#f

left, chaining

90

postfix x++, x--

postfix

80

!x, -x, ++x, --x, new C

prefix

70

*, /, %, /t, %t

left

60

+, -, ^

left

40

==, !=, <, <=, >, >=, is, as

non-associative

30

eager &, short-circuit &&

left

20

eager |, short-circuit ||, if

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.