At 10:36 PM +0300 5/11/10, Eitan Adler wrote:
My proposal is simple:
require that any if statement that compares a constant to a mutable variable
be written as
if (constant == variable)
instead of
if (variable == constant)

this prevents an extremely common programming error
if (variable = constant)


I did this for awhile in my own programming, long enough ago that
there was no cool "yoda" name connected to it.  But I found that in
some situations it makes the code harder to read, so I don't do it
as much any more.  I don't mind if people do it, but I do not think
it should be an official recommendation in style(9).  Or to say it
another way, I'd be annoyed if an otherwise-correct patch was asked
to be rewritten just because the developer used (variable == constant)
instead of (constant == variable).

--
Garance Alistair Drosehn     =               [email protected]
Senior Systems Programmer               or   [email protected]
Rensselaer Polytechnic Institute;             Troy, NY;  USA
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[email protected]"

Reply via email to