Operator precedence problem

Ben Bacarisse ben.usenet at bsb.me.uk
Mon Jun 6 16:09:17 EDT 2016


Rustom Mody <rustompmody at gmail.com> writes:
<snip>
> Kernghan/Thomson/Ritchie (dont remember which) actually admitted to the
> fact that these precedences are wrong
<snip>
> The mistake that C creators made was to treat bitwise operators as
> *logical* rather than as *arithmetic*

It was more that they did not take the opportunity to change them.  C
grew out of B, and B had only the one form of & and |.  These were
bitwise operators but, since they they were more often used for logical
combinations of tests, it made sense to give them low precedence.

When && and || were added to C, & and | should probably have been
"bumped up", but when you have a bunch of people who already know B (and
a bunch of B code you might be converting to C) it's easy to see why you
might not make that change.  After all, it's not like the language is
going to used for much more than this experimental Unix thingy!

-- 
Ben.



More information about the Python-list mailing list