Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 12 May 2010 16:39:58 +0200
From:      Dominic Fandrey <kamikaze@bsdforen.de>
To:        freebsd-hackers@freebsd.org
Subject:   Re: proposed change to style(9): require yoda style if statements
Message-ID:  <4BEABDBE.6080107@bsdforen.de>
In-Reply-To: <86zl05thmv.fsf@ds4.des.no>
References:  <AANLkTimCLELSQ9YNZ403_PLhKOQCQTcl9H1bfb1ccRNb@mail.gmail.com>	<4BEA52CB.8080407@bsdforen.de> <86zl05thmv.fsf@ds4.des.no>

next in thread | previous in thread | raw e-mail | index | archive | help
On 12/05/2010 14:43, Dag-Erling Smørgrav wrote:
> Dominic Fandrey <kamikaze@bsdforen.de> writes:
>> I think the pro-yoda faction actually has more convincing arguments,
> 
> Which ones?  Never seen any beyond the basic "helps avoid accidentally
> typing = instead of ==".  It's bollocks, anyway, because a) for every
> (variable == constant) comparison you have ten (variable == variable)
> comparisons and b) good compilers will warn about bare assignments used
> as conditions.
> 
> The only practical effect of Yoda style is to make code harder to read.

The convincing one applies to Java and C++:
if (constant.equals(object))
instead of
if (object != null && object.equals(constant))
actually looks easier to read.

Though you are right about constants being pretty rare.

> Your .sig is strangely appropriate...

Not my invention, this is a pretty common one, used by many people
on the net. I actually have no idea where it comes from.

-- 
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?4BEABDBE.6080107>