From owner-freebsd-hackers@FreeBSD.ORG Tue May 11 20:03:04 2010 Return-Path: Delivered-To: hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7D374106564A for ; Tue, 11 May 2010 20:03:04 +0000 (UTC) (envelope-from lists@eitanadler.com) Received: from mail-vw0-f54.google.com (mail-vw0-f54.google.com [209.85.212.54]) by mx1.freebsd.org (Postfix) with ESMTP id 2C9948FC08 for ; Tue, 11 May 2010 20:03:03 +0000 (UTC) Received: by vws12 with SMTP id 12so999397vws.13 for ; Tue, 11 May 2010 13:03:02 -0700 (PDT) Received: by 10.220.128.202 with SMTP id l10mr1202468vcs.57.1273606591167; Tue, 11 May 2010 12:36:31 -0700 (PDT) MIME-Version: 1.0 Received: by 10.220.122.31 with HTTP; Tue, 11 May 2010 12:36:11 -0700 (PDT) From: Eitan Adler Date: Tue, 11 May 2010 22:36:11 +0300 Message-ID: To: hackers@freebsd.org Content-Type: text/plain; charset=UTF-8 X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Cc: Subject: 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: Tue, 11 May 2010 20:03:04 -0000 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.