coding style for who.c

Rob Landley rob at landley.net
Sun Mar 12 05:15:57 UTC 2006


On Saturday 11 March 2006 11:27 pm, Paul Fox wrote:
>  > > It is more to make explicit that you want an '=' instead of an '=='
>  > > here than to improve readability, likewise for &, |, ... vs &&,
>  >
>  > For & the C precedence rules are actually wrong, it should bind
>  > _tighter_ than == and friends, but doesn't because way back in the day
>  > there was no && and & was used for decision making.  Meaning x==2 & y
>  > had to be (x==2) & y, not x == (2 & y), because & had to fill in for &&.
>  >
>  > By the time && was introduced, retroactively changing the precedence of
>  > & would have broken too much existing code.  So there you can't get away
>  > from the parentheses...
>
> do you have a citation for this?  i've never before heard that &
> preceded &&, implementation-wise.  all i remember was a quote
> from either "K" or "R" saying that they thought that this
> precedence botch was one of their great regrets.  or somesuch.

Dennis Ritchie has a page on the history of the development of the C language 
that mentions this.

http://cm.bell-labs.com/cm/cs/who/dmr/chist.html

I vaguely recall getting something similar from Peter Salus, possibly from his 
book "A quarter century of Unix", or possibly just talking to him.

One of my many hobbies is computer historian.  I dig this sort of stuff up for 
fun, and tend to remember where I got it. :)

Rob
-- 
Never bet against the cheap plastic solution.



More information about the busybox mailing list