Hi Christian, thanks again for your (and Dmitry's) great work on making closures a part of PHP.
Am Donnerstag, den 26.06.2008, 18:23 +0200 schrieb Christian Seiler:
> * I have *not* added any __invoke() magic to normal objects. This is
> mainly due to the simple reason that adding that would not help
> a closure implementation at all. Closures need some engine internal
> magic (use a dynamically created op_array instead of looking one up,
> setting the correct class scope and setting the correct EG(this). And
> as I said: I want to stick with the closure basics for now.
I understand that you want to keep your proposal basic. However I have
the feeling that we need a complete implementation to make closures
really beneficial for our users. I would consider the following features
to be central for a feature complete implementation:
* Class::__invoke() to allow functors[1]. The class "Closure" in
your proposal should also implement that method to make
method_exists() and ext/reflection behave.
* Change the behaviour how method calls are resolved. Method calls
on invokable objects (closures or functors) should work.
cu, Lars
[1] http://en.wikipedia.org/wiki/Functor
[2] Example for a closure assigned to a property:
class View();
{
public $escape;
}
$view = new View();
$view->escape = function($string) {
return htmlentities($string, ENT_QUOTES, 'UTF-8');
}
echo $view->escape("<script>alert(1)</script>");
signature.asc
Description: Dies ist ein digital signierter Nachrichtenteil
