In the \"Introduction\" section of K&R C (2E) there is this paragraph:
C, like any other language, has its blemishes. Some of the operators h
Yes, the situation discussed in the message you link to is the primary gripe with the precedence of operators in C.
Historically, C developed without &&
. To perform a logical AND operation, people would use the bitwise AND, so a==b AND c==d
would be expressed with a==b & c==d
. To facilitate this, ==
had higher precedence than &
. Although &&
was added to the language later, &
was stuck with its precedence below ==
.
In general, people might like to write expressions such as (x&y) == 1
much more often than x & (y==1)
. So it would be nicer if &
had higher precedence than ==
. Hence people are dissatisfied with this aspect of C operator precedence.
This applies generally to &
, ^
, and |
having lower precedence than ==
, !=
, <
, >
, <=
, and >=
.