coding style for who.c

Dennis Taylor Dennis_T1 at VERIFONE.com
Mon Mar 13 11:55:52 PST 2006


I once worked at a place where the style guide said about operator
precedence something like "If you have to look it up in K&R on
page...then use parenthesis."  One of the team proved the usefulness of
the rule when he loudly proclaimed he had found a bug in the compiler
because it was not following the precedence rules stated in K&R.  It
turns out that he had mistakenly used the wrong instance of the &
operator. :-)  (Now, one could perhaps complain that C abuses &, but
we're stuck with that.)

-----Original Message-----
From: busybox-bounces at busybox.net [mailto:busybox-bounces at busybox.net]
On Behalf Of Rob Landley
Sent: Monday, March 13, 2006 2:05 PM
To: Robin Farine
Cc: busybox at busybox.net
Subject: Re: coding style for who.c

On Monday 13 March 2006 1:54 pm, Robin Farine wrote:
> On Sunday March 12 2006 06:24, Rob Landley wrote:
> > If one of them is a constant, it emits no warning.
>
> Indeed. I could not reproduce any gcc warning with 'if (a & b)', 'a'
> and 'b' being constants or variables. Must be due to a mistake
> while picking mushrooms.

It might have produced a warning on older versions.

if (a & b) doesn't work quite like if (a && b), but it's not the obvious
error 
that if (a = b) tends to be.  If you restrict yourself to logic values
rather 
than arbitrary numbers, and don't mind losing the short circuit
behavior, 
then something if (a==b & c==d) will in fact work as expected.

> Robin

Rob
-- 
Never bet against the cheap plastic solution.
_______________________________________________
busybox mailing list
busybox at busybox.net
http://busybox.net/cgi-bin/mailman/listinfo/busybox




More information about the busybox mailing list