[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Ternary operator patch
- From: Roberto Ierusalimschy <roberto@...>
- Date: Thu, 16 Sep 2010 13:18:24 -0300
> > 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
- References:
- Re: Ternary operator patch, David Kastrup
- Re: Ternary operator patch, Miles Bader
- Re: Ternary operator patch, David Kastrup
- Re: Ternary operator patch, Ryota Hirose
- Re: Ternary operator patch, David Kastrup
- Re: Ternary operator patch, Ryota Hirose
- Re: Ternary operator patch, David Kastrup
- Re: Ternary operator patch, Roberto Ierusalimschy
- Re: Ternary operator patch, David Given
- Re: Ternary operator patch, Tony Finch