From owner-freebsd-arch@FreeBSD.ORG Tue Feb 1 18:06:32 2005 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id E080216A4CF for ; Tue, 1 Feb 2005 18:06:32 +0000 (GMT) Received: from mail24.sea5.speakeasy.net (mail24.sea5.speakeasy.net [69.17.117.26]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8FD4443D49 for ; Tue, 1 Feb 2005 18:06:32 +0000 (GMT) (envelope-from jmg@hydrogen.funkthat.com) Received: (qmail 19902 invoked from network); 1 Feb 2005 18:06:32 -0000 Received: from gate.funkthat.com (HELO hydrogen.funkthat.com) ([69.17.45.168]) (envelope-sender ) by mail24.sea5.speakeasy.net (qmail-ldap-1.03) with SMTP for ; 1 Feb 2005 18:06:32 -0000 Received: from hydrogen.funkthat.com (ipknwl@localhost.funkthat.com [127.0.0.1])j11I6QGH049744; Tue, 1 Feb 2005 10:06:26 -0800 (PST) (envelope-from jmg@hydrogen.funkthat.com) Received: (from jmg@localhost) by hydrogen.funkthat.com (8.12.10/8.12.10/Submit) id j11I6OZ3049743; Tue, 1 Feb 2005 10:06:24 -0800 (PST) Date: Tue, 1 Feb 2005 10:06:24 -0800 From: John-Mark Gurney To: Paul Richards Message-ID: <20050201180624.GB19624@funkthat.com> Mail-Followup-To: Paul Richards , arch@freebsd.org References: <20050128173327.GI61409@myrddin.originative.co.uk> <20050131102630.GJ61409@myrddin.originative.co.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20050131102630.GJ61409@myrddin.originative.co.uk> User-Agent: Mutt/1.4.1i X-Operating-System: FreeBSD 4.2-RELEASE i386 X-PGP-Fingerprint: B7 EC EF F8 AE ED A7 31 96 7A 22 B3 D8 56 36 F4 X-Files: The truth is out there X-URL: http://resnet.uoregon.edu/~gurney_j/ X-Resume: http://resnet.uoregon.edu/~gurney_j/resume.html cc: arch@freebsd.org Subject: Re: c99/c++ localised variable definition X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: John-Mark Gurney List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Feb 2005 18:06:33 -0000 Paul Richards wrote this message on Mon, Jan 31, 2005 at 10:26 +0000: [...] > I think the loop usage though is one clear example where it is > clearer. I think there are others as well; where the usage of the > variable is clearly localised it is much easier to see a local > definition than to have to jump back and forth to find out what > variables are. I personally think it isn't. One thing that I do in python all to regularly (because it lacks variable declarations), is attempt to do: for i in foo: for j in bar: for i in baz: And wonder why i gets such a strange value... It appears that unless you have WARNS=4 set, warnings about: t.c:10: warning: declaration of 'i' shadows a previous local don't show up. So, I would say we HAVE to get the tree building with WARNS=4 and -Werror before we let this into style(9)... Requiring variables at the top require people to think about variable names, and as others have stated, if you need local scoped variables, you're probably better off creating a new function. /me notes it's anoying that gcc accepts -std=c99 and not -std=C99. -- John-Mark Gurney Voice: +1 415 225 5579 "All that I will do, has been done, All that I have, has not."