Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:28487 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 9111 invoked by uid 1010); 20 Mar 2007 18:10:49 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 9096 invoked from network); 20 Mar 2007 18:10:49 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 20 Mar 2007 18:10:49 -0000 Authentication-Results: pb1.pair.com smtp.mail=andrei@gravitonic.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=andrei@gravitonic.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain gravitonic.com from 204.11.219.139 cause and error) X-PHP-List-Original-Sender: andrei@gravitonic.com X-Host-Fingerprint: 204.11.219.139 mail.lerdorf.com Linux 2.5 (sometimes 2.4) (4) Received: from [204.11.219.139] ([204.11.219.139:47389] helo=lerdorf.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id B9/51-33452-7A320064 for ; Tue, 20 Mar 2007 13:10:49 -0500 Received: from [66.228.175.145] (borndress-lm.corp.yahoo.com [66.228.175.145]) (authenticated bits=0) by lerdorf.com (8.13.8/8.13.8/Debian-3) with ESMTP id l2KIAXkf031197; Tue, 20 Mar 2007 11:10:33 -0700 In-Reply-To: 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> Mime-Version: 1.0 (Apple Message framework v624) Content-Type: text/plain; charset=US-ASCII; format=flowed Message-ID: <2b2f60dc7b3112ac164aba20fbddd29d@gravitonic.com> Content-Transfer-Encoding: 7bit Cc: "Stas Malyshev" , "Andi Gutmans" , "Robert Cummings" , , "Sean Coates" Date: Tue, 20 Mar 2007 11:12:09 -0700 To: Wez Furlong X-Mailer: Apple Mail (2.624) X-Virus-Scanned: ClamAV 0.90.1/2880/Mon Mar 19 22:04:21 2007 on colo X-Virus-Status: Clean Subject: Re: [PHP-DEV] PATCH: anonymous functions in PHP From: andrei@gravitonic.com (Andrei Zmievski) I've been wanting a true first-class callable type for a while. -Andrei On Mar 19, 2007, at 5:02 PM, Wez Furlong wrote: > > The second possibility would be to make a first-class callable zval > type which stores that information in the return value from the > function declaration. The callable type would store a pointer to the > op_array as well as a hash table to use to initialize the local scope > of the function. Again, this would be created based on the $_SCOPES > fixup information, and again, $_SCOPES['i'] would be rewritten as > simply $i in the op_array. > > So the funcs array might look like this is var_dump()'d: > > 0 => callable('__anon_0', array('i' => 0)), > 1 => callable('__anon_0', array('i' => 1)), > 2 => callable('__anon_0', array('i' => 2)) > > Adding a type seems cleaner, but obviously requires more work as the > rest of the internals need to understand what to do with it. > > > A third possibility is similar to the second, but a bit less invasive. > Create a callable class type to encapsulate that information. The > rest of the internals would see $funcs[0] as an object, but the engine > would know that calling it will invoke the appropriate function, > prepping the local scope as described above. > > > --Wez. >