Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:71676 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 9131 invoked from network); 28 Jan 2014 16:08:03 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 28 Jan 2014 16:08:03 -0000 Authentication-Results: pb1.pair.com header.from=ajf@ajf.me; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=ajf@ajf.me; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain ajf.me designates 198.187.29.247 as permitted sender) X-PHP-List-Original-Sender: ajf@ajf.me X-Host-Fingerprint: 198.187.29.247 imap4-3.ox.registrar-servers.com Received: from [198.187.29.247] ([198.187.29.247:39677] helo=imap4-3.ox.registrar-servers.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C2/31-01140-2E5D7E25 for ; Tue, 28 Jan 2014 11:08:03 -0500 Received: from localhost (localhost [127.0.0.1]) by oxmail.registrar-servers.com (Postfix) with ESMTP id F28E056007D; Tue, 28 Jan 2014 11:07:59 -0500 (EST) X-Virus-Scanned: Debian amavisd-new at imap4.ox.registrar-servers.com Received: from oxmail.registrar-servers.com ([127.0.0.1]) by localhost (imap4.ox.registrar-servers.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id MdkJ-AMBLqzd; Tue, 28 Jan 2014 11:07:59 -0500 (EST) Received: from [192.168.0.200] (unknown [176.25.177.94]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by oxmail.registrar-servers.com (Postfix) with ESMTPSA id 3F839560075; Tue, 28 Jan 2014 11:07:59 -0500 (EST) Message-ID: <52E7D5DD.4080608@ajf.me> Date: Tue, 28 Jan 2014 16:07:57 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 MIME-Version: 1.0 To: George Bond , PHP internals list References: <1796143171.126442.1390903281925.open-xchange@app2.ox.registrar-servers.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Lexical scoping From: ajf@ajf.me (Andrea Faulds) On 28/01/14 13:36, George Bond wrote: > Alternatively, you could say that the ultimate problem is that we don't > have strong scoping - braces only define flow control, not scope. So you > could introduce a strong-scoping structure. Maybe a double brace? > > foreach( $array as &$a ){{ > $a = 3; > }} > var_dump( $a ); // E_NOTICE, $a is now undefined > > You could even say that an isolated brace pair (ie not one following a > control statement) *always* produces a scope. My proposal is to add optional strong scoping. As JavaScript has var for function-scoped variables and ECMAScript Harmony will add let for lexically-scoped variables, I'm proposing something similar here. It would allow you to scope to the block, if you so desire. -- Andrea Faulds http://ajf.me/