Re: Re: PATCH: anonymous functions in PHP

From: Date: Thu, 20 Dec 2007 17:25:21 +0000
Subject: Re: Re: PATCH: anonymous functions in PHP
References: 1 2 3 4 5 6 7 8 9 10  Groups: php.internals 
Request: Send a blank email to internals+get-34145@lists.php.net to get a copy of this message
On 12/20/07, Stanislav Malyshev <stas@zend.com> wrote: > > being able to do the following (and not to worry about runtime > > compilation) is a good reason on it's own: > > > > array_filter($my_data, function($test){ return 3 === ($test % 4) }); > > What's wrong with regular functions? I wrote in in thread, already, but here is the summary: 1) you need to declare them somewhere, which doesn't make much sense if these functions are meant to be used only in such context. Sometimes there are even problem to give meaningful names to such functions 2) inline-function is a good candidate for automatic optimization (in case of array_filter, array_map and similiar the construction can be converted to the loop) 3) as the result of (1) and (2) it can be used for fast "currying" of other functions -- Alexey Zakhlestin http://blog.milkfarmsoft.com/

« previous php.internals (#34145) next »