Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:28437 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 50984 invoked by uid 1010); 19 Mar 2007 19:45:40 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 50960 invoked from network); 19 Mar 2007 19:45:40 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 Mar 2007 19:45:40 -0000 Authentication-Results: pb1.pair.com smtp.mail=sean@caedmon.net; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=sean@caedmon.net; sender-id=unknown Received-SPF: error (pb1.pair.com: domain caedmon.net from 69.60.120.90 cause and error) X-PHP-List-Original-Sender: sean@caedmon.net X-Host-Fingerprint: 69.60.120.90 iconoclast.caedmon.net Linux 2.4/2.6 Received: from [69.60.120.90] ([69.60.120.90:42171] helo=iconoclast.caedmon.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 78/CA-01604-168EEF54 for ; Mon, 19 Mar 2007 14:45:39 -0500 Received: from localhost ([127.0.0.1]) by iconoclast.caedmon.net with esmtp (Exim 3.35 #1 (Debian)) id 1HTNn5-0001Ms-00; Mon, 19 Mar 2007 15:45:12 -0400 Message-ID: <45FEE848.9080304@caedmon.net> Date: Mon, 19 Mar 2007 15:45:12 -0400 User-Agent: Thunderbird 1.5.0.9 (X11/20070103) MIME-Version: 1.0 To: Wez Furlong CC: Stanislav Malyshev , 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> X-Enigmail-Version: 0.94.2.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: Re: [PHP-DEV] PATCH: anonymous functions in PHP From: sean@caedmon.net (Sean Coates) If we can solve the scoping problem (perhaps via references as you mentioned), then lexical (or another keyword, to be debated endlessly for months, whose name-debate will delay the implementation of this functionality, but I digress...) seems like a good solution to grabbing scope, and fits the "PHP Way", IMO. > 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: This was my next question (-: > 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 > tracking per zend_function so that we know that we need to do that step > during binding. JavaScript (and I suspect other Lisp-like languages) solves this by making the function an actual closure—the defined function maintains access to the parent scope, even after the parent's hash table (or however it works in JS) would have normally been destroyed. I think the key thing to remember here is that JS is fundamentally different from PHP. Functions are objects in JS, and they always have access to variables from all parent scopes. I don't think PHP can (or should) ever implement this. I also don't know what I'm talking about when it comes to ZE internals, so if I'm way off base, feel free to put me in line (-: (I maintain that JS' wonky (though useful) scoping rules should never be assimilated in PHP.) S