From owner-freebsd-hackers@FreeBSD.ORG Wed May 12 07:20:33 2010 Return-Path: Delivered-To: hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id CEF81106564A for ; Wed, 12 May 2010 07:20:33 +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 9257D8FC12 for ; Wed, 12 May 2010 07:20:33 +0000 (UTC) Received: from mobileKamikaze.norad (unknown [188.46.113.157]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.bsdforen.de (Postfix) with ESMTP id 9FEC68A1D03; Wed, 12 May 2010 09:03:43 +0200 (CEST) Message-ID: <4BEA52CB.8080407@bsdforen.de> Date: Wed, 12 May 2010 09:03:39 +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: Eitan Adler References: In-Reply-To: X-Enigmail-Version: 1.0.1 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Cc: hackers@freebsd.org 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 07:20:33 -0000 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?