From: Ian Jackson Subject: Re: [PATCH RFC v2 06/13] libxl: permit declaration after statement Date: Mon, 28 Nov 2011 16:40:06 +0000 Message-ID: <20179.47462.815671.301622@mariner.uk.xensource.com> References: <1319827031-15395-1-git-send-email-ian.jackson@eu.citrix.com> <1319827031-15395-2-git-send-email-ian.jackson@eu.citrix.com> <1319827031-15395-3-git-send-email-ian.jackson@eu.citrix.com> <1319827031-15395-4-git-send-email-ian.jackson@eu.citrix.com> <1319827031-15395-5-git-send-email-ian.jackson@eu.citrix.com> <1319827031-15395-6-git-send-email-ian.jackson@eu.citrix.com> <1319827031-15395-7-git-send-email-ian.jackson@eu.citrix.com> <1320054652.23193.28.camel@zakaz.uk.xensource.com> <20145.29085.278257.629473@mariner.uk.xensource.com> <1320263024.3084.61.camel@cthulhu.hellion.org.uk> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Stefano Stabellini Cc: "xen-devel@lists.xensource.com" , Ian Campbell List-Id: xen-devel@lists.xenproject.org Stefano Stabellini writes ("Re: [Xen-devel] [PATCH RFC v2 06/13] libxl: permit declaration after statement"): > I think it would make sense to add to the CODING_STYLE that variable > declarations shouldn't be mixed with code, unless part of a macro or an > alloca-like construct. I think this is a silly rule. In my proposed commit message I advanced three reasons for allowing declaration after statement: > > * It allows variables to be more often initialised as they are > > declared, thus reducing the occurrence of uninitialised variable > > errors. > > > > * Certain alloca-like constructs (arrays allocated at runtime on the > > stack) can more often be written without a spurious { } block. > > Such blocks are confusing to read. > > > > * It makes it easier to write and use macros which declare and > > initialise formulaic variables and do other function setup code, > > because there is no need to worry that such macros might be > > incompatible with each other or have strict ordering constraints. Of these the first two improvements would be banned by your proposed coding style rule. I don't understand what the harm is in allowing declarations, with initialisation, freely mixed with code. Ian.