Postfix funcall, arraysub, dot, and arrow; and ++ --
ABOVE unary e.g. the very common *p++
The latter yes, but not the former. Arithmetic treats negation as
additive, but since (add,mul) are a field it never makes a difference.
Except for artifacts of (computer) typing, e.g. in C unsigned vs
signed, only with exponentiation added can you tell the difference.
And in Fortran, which has exponentiation (and as the first language
designed for numerics tried to follow math as well as it could)
negation binds with add&sub and - X ** Y is - (X**Y) not (-X)**Y .
(And so does unary + for symmetry, although it accomplishes nothing.)
And then it would have a (minor) problem vs math. But it doesn't.
Comparison below arith, and logic lower yet, I concur.
And similarly & | but ^ is not so intuitive to me.
(Most?) Other 3GLs have assignment as a statement not an operator, and
hence 'below the bottom' of the operator precedence list. Putting it
above comma and incomparable with ?: is close enough for me.
See below.
Mostly I agree with the above, but there are two or three notable
exceptions.
The least notable exception is the shift operators, which seem
natural to put in with the multiply-level operators.
At the other end of the precedence scale, to me assignment makes
sense where it is. All the operators above it (not counting ++
and --) yield values without side-effects, and you want to do
something with the value, so assignment should be right near the
bottom so those values can be stored. The one operator below
assignment, comma, clearly seems designed to partition operators
that have side-effects, so it naturally goes below assignment.
The precedence choice that seems most wrong is the bitwise boolean
operators; these would be better just above the comparison
operators (both relational and equality), rather than just below.
I remember reading somewhere that Dennis Ritchie said he would
change that now if he could (originally C didn't have && and ||)
but of course it's too late now to change it.
Concur with both: they would have been nicer above comparison, but
historically it couldn't have happened.