Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:28438 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 73006 invoked by uid 1010); 19 Mar 2007 20:15:27 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 72991 invoked from network); 19 Mar 2007 20:15:27 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 Mar 2007 20:15:27 -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.114 as permitted sender) X-PHP-List-Original-Sender: stas@zend.com X-Host-Fingerprint: 63.205.162.114 unknown Windows 2000 SP4, XP SP1 Received: from [63.205.162.114] ([63.205.162.114:2319] helo=us-ex1.zend.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 78/AD-01604-D5FEEF54 for ; Mon, 19 Mar 2007 15:15:27 -0500 Received: from [127.0.0.1] ([192.168.16.109]) by us-ex1.zend.com with Microsoft SMTPSVC(6.0.3790.1830); Mon, 19 Mar 2007 13:15:18 -0700 Message-ID: <45FEEF52.1060002@zend.com> Date: Mon, 19 Mar 2007 13:15:14 -0700 Organization: Zend Technologies User-Agent: Thunderbird 2.0b2 (Windows/20070116) MIME-Version: 1.0 To: Wez Furlong CC: Sean Coates , internals@lists.php.net References: <86478A67-DCA2-4000-9EF0-DA4338E8389B@omniti.com> <45FDF031.4010508@zend.com> <45FE2312.1050506@zend.com> <45FED6D9.8030307@caedmon.net> <45FEDAE5.2010309@zend.com> <45FEE396.7040905@caedmon.net> <0757BDEA-65F5-4123-B647-060DCA84B4B0@omniti.com> In-Reply-To: <0757BDEA-65F5-4123-B647-060DCA84B4B0@omniti.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 19 Mar 2007 20:15:18.0041 (UTC) FILETIME=[5008D090:01C76A63] Subject: Re: [PHP-DEV] PATCH: anonymous functions in PHP From: stas@zend.com (Stanislav Malyshev) > I've been thinking about this on and off today too. > Something along the lines of the following is more in the PHP spirit: > > $ver = phpversion(); > $fancyVer = function () { lexical $ver; return "PHP $ver"; }; > > Where "lexical" is a keyword that means "inherit this variable from the > current lexical scope". I'm not suggesting that this is a good name for > the keyword, it's just something that springs to mind. How this is going to work? Variables are not interpreted by the compiler now... > So, given some way to explicitly reference the scope where the function > was "defined", what happens when you call $fancyVer after that scope has > gone away: Exactly! That's why it is hard to do closures in PHP :) > This could perhaps be solved by taking a reference to $ver when the > function is bound, but I don't know enough about the ZE to understand > the implications of that; it would probably require a bit more state $ver would not even exist when we compile it - $ver appears in run-time and we want function to be created in compile-time! -- Stanislav Malyshev, Zend Products Engineer stas@zend.com http://www.zend.com/