From owner-freebsd-arch@FreeBSD.ORG Tue Feb 1 20:30:44 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 1900716A4CE for ; Tue, 1 Feb 2005 20:30:44 +0000 (GMT) Received: from ns1.xcllnt.net (209-128-86-226.BAYAREA.NET [209.128.86.226]) by mx1.FreeBSD.org (Postfix) with ESMTP id D239443D1F for ; Tue, 1 Feb 2005 20:30:43 +0000 (GMT) (envelope-from marcel@xcllnt.net) Received: from [192.168.4.250] (dhcp50.pn.xcllnt.net [192.168.4.250]) by ns1.xcllnt.net (8.13.1/8.13.1) with ESMTP id j11KUdea012213; Tue, 1 Feb 2005 12:30:41 -0800 (PST) (envelope-from marcel@xcllnt.net) In-Reply-To: <20050201190416.GG61409@myrddin.originative.co.uk> References: <20050128173327.GI61409@myrddin.originative.co.uk> <20050131102630.GJ61409@myrddin.originative.co.uk> <20050201180624.GB19624@funkthat.com> <20050201190416.GG61409@myrddin.originative.co.uk> Mime-Version: 1.0 (Apple Message framework v619.2) Content-Type: text/plain; charset=US-ASCII; format=flowed Message-Id: Content-Transfer-Encoding: 7bit From: Marcel Moolenaar Date: Tue, 1 Feb 2005 12:30:37 -0800 To: Paul Richards X-Mailer: Apple Mail (2.619.2) 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 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 20:30:44 -0000 On Feb 1, 2005, at 11:04 AM, Paul Richards wrote: >> 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)... > > The issue with shadowing outer scope variables is only an issue if > you need to access them. If your only using the syntax for loop > variables to do the looping then there's no issue. Never forget that you want to be able to debug you application. While technically you're right, it's bad practice to do so. In general, localized variable definitions increases the chance that a bug is being made, because it increases the complexity of the language -- there are more things/cases to be aware off and that need checking before you can be sure the code is correct. Hence, there's more you can forget about when you code. Therefore, it's not a feature you want to promote. Put differently: it doesn't fundamentally change the expression power of the language, but rather introduce new ways of doing things that can already be done. It doesn't buy you anything. It's just window- dressing. It would have been very adequate if it were kept as a C++ (or more correctly object oriented) feature only... -- Marcel Moolenaar USPA: A-39004 marcel@xcllnt.net