Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:28491 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 35681 invoked by uid 1010); 20 Mar 2007 18:56:38 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 35665 invoked from network); 20 Mar 2007 18:56:38 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 20 Mar 2007 18:56:38 -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:56499] helo=us-ex1.zend.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id F5/91-21779-66E20064 for ; Tue, 20 Mar 2007 13:56:38 -0500 Received: from [127.0.0.1] ([192.168.16.109]) by us-ex1.zend.com with Microsoft SMTPSVC(6.0.3790.1830); Tue, 20 Mar 2007 11:56:35 -0700 Message-ID: <46002E60.4050308@zend.com> Date: Tue, 20 Mar 2007 11:56:32 -0700 Organization: Zend Technologies User-Agent: Thunderbird 2.0b2 (Windows/20070116) MIME-Version: 1.0 To: Wez Furlong CC: Andi Gutmans , internals@lists.php.net, Sean Coates 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> <45FEEF52.1060002@zend.com> <1174336464.24632.110.camel@blobule> <45FEF9A5.4050409@zend.com> <1174338801.24632.124.camel@blobule> <45FEFDCE.7050100@zend.com> <1174339527.24632.129.camel@blobule> <45FF01FE.6070504@zend.com> <698DE66518E7CA45812BD18E807866CE185525@us-ex1.zend.net> <2b2f60dc7b3112ac164aba20fbddd29d@gravitonic.com> <460025EA.5050303@zend.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 20 Mar 2007 18:56:35.0850 (UTC) FILETIME=[7BCD66A0:01C76B21] Subject: Re: [PHP-DEV] PATCH: anonymous functions in PHP From: stas@zend.com (Stanislav Malyshev) > Either that, or you need to store it in the op_array, which is "bad" > because you don't know when you can free that closure state, so you have > to carry it around for the rest of the request. Well, this is a strong argument indeed. However adding new zval type is a big step which adds complexity to the language and tools. We'd also have to modify a bunch of places where callbacks are used to allow this. I think though there's a middle way - if we modify callback type so that instead of array($object, $name) it would accept array($object, $name, $arguments) where arguments are the captured closure variables it might be more convenient. The advantage is that if we don't have closure variables, we don't need to do a thing. We'd need also to deal with decision if we create closure in a class context would it belong to class or global space. > I agree about $_SCOPES['foo']. I'm actually starting to lean towards > just copying the entire local scope hash table and storing it in the > callable/closure, and using that to initialize the symtable when you > call into the function. That might be not that good an idea. Local table can be very large (and what if it's global scope?), include all kinds of things you won't ever need (such as resources used locally) and the user regards it as transient and doesn't necessarily want to capture it into closure. Even worse, non-closure anon function - i.e. not wanting to use any of the parent context - would then still have the penalty of carrying all the stuff around. I think explicitly declaring might be the best way... -- Stanislav Malyshev, Zend Products Engineer stas@zend.com http://www.zend.com/