coding style for who.c
Robin Farine
robin.farine at terminus.org
Sun Mar 12 00:30:26 UTC 2006
On Saturday March 11 2006 22:23, Rob Landley wrote:
> On Saturday 11 March 2006 2:26 pm, Robin Farine wrote:
> > On Saturday March 11 2006 19:50, Devin Bayer wrote:
> > > In addition, I dislike having to make
> > > if(a = strchr(str,'-'));
> > > into
> > > if((a = strchr(str,'-')));
> > >
> > > How can the second one be considered easier to read? To fix
> > > this you need to add -Wno-parentheses to the CPPFLAGS.
> >
> > 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 &&.
Ah yes, I have been bitten by this and completely agree with the
non-intuitive character of this precedence rule. But I was thinking
of the warning gcc emits when one writes 'if (a & b)' instead of
'if (a && b)' or 'if ((a & b))' where I think the double parenthesis
clears the ambiguity and thus are worth the little loss of
readability.
Robin
More information about the busybox
mailing list