lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


> > But what's the issue with & and |? & has a higher priority than |, which
> > is what I'd expect (boolean multiply vs boolean add).
> 
> The problem is their precedence relative to the comparison operators.
> 
>  if (a & 15 == 0) fail();

Ritchie, in his HOPL paper [1], called this "an infelicity of C's
precedence rules". The problem came from B, which did not have && and
||; & and | were used for logical operations, and therefore had quite
low priorities.

[1] Dennis Ritchie, "The Development of the C Programming Language".
HOPL II, ACM Press, 1996.

-- Roberto