Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:47042 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 44337 invoked from network); 24 Feb 2010 06:56:32 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 24 Feb 2010 06:56:32 -0000 Authentication-Results: pb1.pair.com header.from=stas@zend.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=stas@zend.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain zend.com designates 63.205.162.117 as permitted sender) X-PHP-List-Original-Sender: stas@zend.com X-Host-Fingerprint: 63.205.162.117 us-mr1.zend.com Received: from [63.205.162.117] ([63.205.162.117:41867] helo=us-mr1.zend.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C9/88-26388-E9DC48B4 for ; Wed, 24 Feb 2010 01:56:31 -0500 Received: from us-gw1.zend.com (us-ex1.zend.net [192.168.16.5]) by us-mr1.zend.com (Postfix) with ESMTP id B26D243FCE for ; Tue, 23 Feb 2010 22:55:22 -0800 (PST) Received: from [192.168.27.13] ([192.168.27.13]) by us-gw1.zend.com with Microsoft SMTPSVC(6.0.3790.3959); Tue, 23 Feb 2010 22:56:28 -0800 Message-ID: <4B84CD95.7030206@zend.com> Date: Tue, 23 Feb 2010 22:56:21 -0800 Organization: Zend Technologies User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.7) Gecko/20100111 Lightning/1.0b2pre Thunderbird/3.0.1 MIME-Version: 1.0 To: internals@lists.php.net References: <4B54FC87.8070106@zend.com> <4F.56.22457.408955B4@pb1.pair.com> <4B55D850.8000604@zend.com> <4B808294.1070801@keryx.se> <4B844DBA.4050804@zend.com> <4B845E0C.7040005@gmail.com> In-Reply-To: <4B845E0C.7040005@gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 24 Feb 2010 06:56:28.0186 (UTC) FILETIME=[7CDB17A0:01CAB51E] Subject: Re: [PHP-DEV] On closures and lamdba From: stas@zend.com (Stanislav Malyshev) Hi! > Correct me if I'm wrong, but given the fact that PHP only* supports > functions defined in the global space**, with the additional ability to > import global variables using the global statement, wouldn't that make > named functions able to close-over global variables? It's different mechanism. Globals are just references to variables in same global scope, they are not bound to any function, etc. > And, if the above is true, wouldn't it be consistent to support the use > statement on named functions, and then deprecate the global statement? That's why I'm not a big fan of that "consistency" argument here on the list - because it usually means "let's implement some feature because I like it", but not more. Which is fine, but it has nothing to do with consistency. Particularly, scope capturing and all that has very little relation to what globals do. Closures carry around "captured" variables. Regular functions don't. Global scope exists independently of them. The mechanism is similar (well, it's the same engine, how many there can be? :) but they are not the same. > ** namespaced functions don't make any difference, as variables aren't > namespaced. I'm not sure what you mean here, as variables in PHP are scoped. Global functions are not scoped, of course, but can be namespaced. -- Stanislav Malyshev, Zend Software Architect stas@zend.com http://www.zend.com/ (408)253-8829 MSN: stas@zend.com