Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:28538 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 92745 invoked by uid 1010); 21 Mar 2007 16:31:05 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 92730 invoked from network); 21 Mar 2007 16:31:05 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 21 Mar 2007 16:31:05 -0000 X-Host-Fingerprint: 12.226.174.98 12-226-174-98.client.mchsi.com Received: from [12.226.174.98] ([12.226.174.98:15451] helo=localhost.localdomain) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 72/02-09395-9CD51064 for ; Wed, 21 Mar 2007 11:31:05 -0500 Message-ID: <72.02.09395.9CD51064@pb1.pair.com> To: internals@lists.php.net Date: Wed, 21 Mar 2007 11:33:00 -0500 User-Agent: Thunderbird 2.0b2 (Windows/20070116) MIME-Version: 1.0 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> <698DE66518E7CA45812BD18E807866CE18559A@us-ex1.zend.net> <40259.216.230.84.67.1174435351.squirrel@www.l-i-e.com> In-Reply-To: <40259.216.230.84.67.1174435351.squirrel@www.l-i-e.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Posted-By: 12.226.174.98 Subject: Re: [PHP-DEV] PATCH: anonymous functions in PHP From: dragonwing@dragonu.net (Jacob Santos) So does this mean that the patch would be included even in its somewhat broken state? Just don't allow it in loops or warn when it is or access to outside scope variables. I need to get VLD working on Windows to see what the fuss is all about. I thought everything is compiled to oplines, if that is so, then why not back up to the previous function space, keep the scope when you encounter an inside function, which should be assumed to be a closure. If you compile and store the closure function in top level userspace, then it should be able to be accessed at runtime. function test() { $f = function () { return 0; } return $f; } $closure = test(); $closure(); Err, Pseudo-oplines, but since I don't exactly know anything about PHP opcodes, I'm just pulling this stuff out of my ass. CREATE_FUNCTION test CREATE_FUNCTION zend_anon_0 RET_VAL 0 END_FUNCTION END_FUNCTION CALL 'test' ASSIGN $0, $valuefunction (I have to admit that I'm not that far in Assembler for procedures (yes, I'm a kook, but I can change baby, just give me another chance) and I apologize, but thanks for reading this far!) CALL $0 In which at run time the following can be replaced with: CREATE_FUNCTION 'zend_anon_0' RET_VAL 0 END_FUNCTION CREATE_FUNCTION 'test' RET_CLOSURE 'zend_anon_0' END_FUNCTION CALL 'test' CALL 'zend_anon_0' I do recall that parameters are passed somewhere. Eh. Aside from getting the Oplines, opcodes, as well as the instruction names wrong, and pretty much everything. What else is wrong with this? > But if that's the best that can be done with the resources available, > I think it would be a good compromise. > > Especially as it leaves open the possiblity of someday nailing down a > complete clear definition of what the scoping rules turn out to be, > with room for experimentation in the meantime without violating BC. >