Re: (0 == foo), rather than (foo == 0)

From: Linus Torvalds
Date: Wed Mar 10 2004 - 21:31:21 EST

On Thu, 11 Mar 2004, Peter Williams wrote:
> Richard B. Johnson wrote:
> >
> > People who develop kernel code know the difference between
> > '==' and '=' and are never confused my them.
> And you never make typing mistakes? That's admirable or should I say
> incredible.

The thing is, people tend to make fewer typing mistakes of that kind, than
just plain logic errors from not thinking right about something.

And while "0 == foo" may be logically the same thing as "foo == 0", the
fact is, the latter is what people are used to seeing. And by being used
to seeing it, they have an easier time thinking about it.

As a result, using the former just tends to increase peoples confusion by
making code harder to read, which in turn tends to increase the chance of

So don't do it. The kind of bug that the "0 == x" syntax protects against
is LESS LIKELY to happen than the kind of bug it tends to cause.

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at