Movatterモバイル変換


[0]ホーム

URL:


Re: PATCH: Implementing closures in PHP

From:Ryusuke SEKIYAMADate:Fri, 28 Dec 2007 16:45:03 +0000
Subject:Re: PATCH: Implementing closures in PHP
Groups:php.internals 
Request:Send a blank email tointernals+get-34272@lists.php.net to get a copy of this message
>any idea about the possibility of hash conflict?How about this patch?http://www.opendogs.org/pub/php-5.3dev-071228a.patchThis patch is PHP 5.3 version of the patch I have introducedin my blog. (written in Japanese)1.http://d.hatena.ne.jp/rsky/20071126/11960778602.http://d.hatena.ne.jp/rsky/20071128/11962607323.http://d.hatena.ne.jp/rsky/20071130/1196426672This patch contains two features, anonymous function andsquare bracket array syntax.Anonymous function can be used in loop (does not exhaust memoryas create_function() in loop), work with opcode cachesand also can be called directly like JavaScript's one.For example:% php -r 'print_r(array_map(function($n){ return $n * $n; }, [1, 2, 3]));'Array(    [0] => 1    [1] => 4    [2] => 9)% php -r 'function($str){ echo $str, "\n"; }("foo");'fooMore examples are included in this archive:http://www.opendogs.org/pub/php-5.3dev-071228-anon-patch.zip-- /** * Ryusuke SEKIYAMA * rsky0711@gmail.com */

Thread (168 messages)

«previousphp.internals (#34272)next »

[8]ページ先頭

©2009-2025 Movatter.jp