Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:36385 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 95776 invoked from network); 23 Mar 2008 14:49:43 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 23 Mar 2008 14:49:43 -0000 Authentication-Results: pb1.pair.com header.from=helly@php.net; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=helly@php.net; spf=unknown; 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:59286] helo=h1149922.serverkompetenz.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 17/2F-10593-50E66E74 for ; Sun, 23 Mar 2008 09:49:42 -0500 Received: from MBOERGER-ZRH.corp.google.com (72-216.1-85.cust.bluewin.ch [85.1.216.72]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by h1149922.serverkompetenz.net (Postfix) with ESMTP id D415111DB7C; Sun, 23 Mar 2008 15:49:38 +0100 (CET) Date: Sun, 23 Mar 2008 15:46:34 +0100 Reply-To: Marcus Boerger X-Priority: 3 (Normal) Message-ID: <938847429.20080323154634@marcus-boerger.de> To: "Ryusuke SEKIYAMA" CC: "Andrei Zmievski" , "Marcus Boerger" , "Matvey Arye" , "KOYAMA Tetsuji" , In-Reply-To: References: <47B9B1B9.7060601@geminisbs.com> <93D0D6BA-34AD-4A17-B474-91B251628EA5@gravitonic.com> <1068528889.20080223124346@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 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 :-) 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