From owner-freebsd-hackers@FreeBSD.ORG Wed May 12 14:40:00 2010 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 259CA106564A for ; Wed, 12 May 2010 14:40:00 +0000 (UTC) (envelope-from kamikaze@bsdforen.de) Received: from mail.bsdforen.de (bsdforen.de [212.204.60.79]) by mx1.freebsd.org (Postfix) with ESMTP id D9AAC8FC21 for ; Wed, 12 May 2010 14:39:59 +0000 (UTC) Received: from mobileKamikaze.norad (vpn-cl-163-27.rz.uni-karlsruhe.de [141.3.163.27]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.bsdforen.de (Postfix) with ESMTP id CF4238A1CB3 for ; Wed, 12 May 2010 16:39:58 +0200 (CEST) Message-ID: <4BEABDBE.6080107@bsdforen.de> Date: Wed, 12 May 2010 16:39:58 +0200 From: Dominic Fandrey User-Agent: Mozilla/5.0 (X11; U; FreeBSD amd64; en-GB; rv:1.9.1.9) Gecko/20100331 Thunderbird/3.0.4 MIME-Version: 1.0 To: freebsd-hackers@freebsd.org References: <4BEA52CB.8080407@bsdforen.de> <86zl05thmv.fsf@ds4.des.no> In-Reply-To: <86zl05thmv.fsf@ds4.des.no> X-Enigmail-Version: 1.0.1 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: Re: proposed change to style(9): require yoda style if statements X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 May 2010 14:40:00 -0000 On 12/05/2010 14:43, Dag-Erling Smørgrav wrote: > Dominic Fandrey 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?