Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:36422 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 8902 invoked from network); 24 Mar 2008 13:03:37 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 24 Mar 2008 13:03:37 -0000 Authentication-Results: pb1.pair.com smtp.mail=helly@php.net; spf=unknown; sender-id=unknown Authentication-Results: pb1.pair.com header.from=helly@php.net; sender-id=unknown Received-SPF: unknown (pb1.pair.com: domain php.net does not designate 85.214.94.56 as permitted sender) X-PHP-List-Original-Sender: helly@php.net X-Host-Fingerprint: 85.214.94.56 aixcept.net Linux 2.6 Received: from [85.214.94.56] ([85.214.94.56:49288] helo=h1149922.serverkompetenz.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id A3/C0-04656-7A6A7E74 for ; Mon, 24 Mar 2008 08:03:35 -0500 Received: from MBOERGER-ZRH.corp.google.com (84-210.0-85.cust.bluewin.ch [85.0.210.84]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by h1149922.serverkompetenz.net (Postfix) with ESMTP id 50AD011F189; Mon, 24 Mar 2008 14:03:32 +0100 (CET) Date: Mon, 24 Mar 2008 14:03:01 +0100 Reply-To: Marcus Boerger X-Priority: 3 (Normal) Message-ID: <4251492.20080324140301@marcus-boerger.de> To: "Alexey Zakhlestin" CC: "Ryusuke SEKIYAMA" , "Andrei Zmievski" , "Matvey Arye" , "KOYAMA Tetsuji" , In-Reply-To: References: <47B9B1B9.7060601@geminisbs.com> <93D0D6BA-34AD-4A17-B474-91B251628EA5@gravitonic.com> <1068528889.20080223124346@marcus-boerger.de> <938847429.20080323154634@marcus-boerger.de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Subject: Re: [PHP-DEV] [RFC] Anonymous functions From: helly@php.net (Marcus Boerger) Hello Alexey, my last update on this was that people were unhappy with closures. If that is not the case than maybe we need to write this as an RFC on the wiki: http://wiki.php.net/rfc So well maybe you're right and it only requires selecting between the two and checking whether there are tiny parts missing. marcus Monday, March 24, 2008, 10:21:57 AM, you wrote: > On 3/23/08, Marcus Boerger wrote: >> Hello Ryusuke, >> >> I have put your proposal as a link to a PHP GSoC 2008 idea here: >> http://wiki.php.net/gsoc/2008 >> >> Feel invited to add to this idea in whatever way you want :-) > how is it related to gsoc? > patches are already there — all we need is to decide which one is > better, and what needs to be fixed. no? >> >> marcus >> >> >> Saturday, February 23, 2008, 7:46:34 PM, you wrote: >> >> > 2008/2/24, Andrei Zmievski : >> >> Do we have a working patch somewhere then? >> >> > Hi, I have added support for closures to my patches. >> >> > http://www.opendogs.org/pub/php-5.3-080223-anon.patch >> > http://www.opendogs.org/pub/php-6.0-080223-anon.patch >> > http://www.opendogs.org/pub/php-anon-tests-080223.tgz >> >> > Example: >> > > > function get_counter($i = 0) >> > { >> > /** >> > * 'static' modified anonymous function's >> > * uninitialized (or null) static variables >> > * are copied from the declared scope. >> > */ >> > return static function(){ >> > static $i; >> > return ++$i; >> > }; >> > } >> >> > $c1 = get_counter(); >> > $c2 = get_counter(100); >> > var_dump($c1(), $c2()); >> > var_dump($c1(), $c2()); >> > var_dump($c1(), $c2()); >> ?>> >> >> > For recursive calling of anonymous functions and closures, >> > added function get_current_function_key(). >> >> > > > $f = function($i = 0) >> > { >> > echo "$i "; >> > if (++$i > 10) { >> > return; >> > } >> > $f = get_current_function_key(); >> > $f($i); >> > }; >> >> > $f(); >> ?>> >> >> >> > And here is a Zend extension for PHP 5.2 which enables >> > anonymous functions, closures and square bracket arrays. >> >> > http://www.opendogs.org/pub/php_qiq-0.1.0pre.tgz >> >> > This has a few more features, but, at present, there is >> > no document... >> >> >> > Regards, >> >> >> >> >> >> Best regards, >> >> Marcus >> >> >> >> -- >> PHP Internals - PHP Runtime Development Mailing List >> To unsubscribe, visit: http://www.php.net/unsub.php >> >> Best regards, Marcus