C and its descendants read x & 1 == 0 as x & (1 == 0), because &, | and ^ bind more
loosely than comparisons there; Rust and Python read it as (x & 1) == 0. Rather than pick one
and let half of its readers misread the code, Auk requires parentheses whenever &, | or ^
is an operand of ==, !=, <, <=, > or >=. Shifts (<<, >>) mean the same in every
language and need none.
Wrong#
fn is_even(x: int): bool = x & 1 == 0Fixed#
fn is_even(x: int): bool = (x & 1) == 0Common causes#
- Testing a flag: write
(flags & READ) != 0. - Comparing a masked value:
(b & 0xc0) == 0x80.