Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 12 May 2010 09:03:39 +0200
From:      Dominic Fandrey <kamikaze@bsdforen.de>
To:        Eitan Adler <lists@eitanadler.com>
Cc:        hackers@freebsd.org
Subject:   Re: proposed change to style(9): require yoda style if statements
Message-ID:  <4BEA52CB.8080407@bsdforen.de>
In-Reply-To: <AANLkTimCLELSQ9YNZ403_PLhKOQCQTcl9H1bfb1ccRNb@mail.gmail.com>
References:  <AANLkTimCLELSQ9YNZ403_PLhKOQCQTcl9H1bfb1ccRNb@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On 11/05/2010 21:36, 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)
> 
> While this is almost always found in testing sometimes thing can slip
> through and writing it using the former method will generate a compiler
> warning.

Is this suggestion due to the discussions around yoda-style in
the comments of:
http://www.globalnerdy.com/2010/05/09/new-programming-jargon/

I think the pro-yoda faction actually has more convincing
arguments, though I never considered using yoda-style myself.

-- 
A: Because it fouls the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail? 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4BEA52CB.8080407>