Re: [PATCH] [RFC] Closures and lambda functions in PHP

From: Date: Sun, 29 Jun 2008 22:04:50 +0000
Subject: Re: [PATCH] [RFC] Closures and lambda functions in PHP
References: 1 2 3 4 5  Groups: php.internals 
Request: Send a blank email to internals+get-38680@lists.php.net to get a copy of this message
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>");

Attachment: [application/pgp-signature] Dies ist ein digital signierter Nachrichtenteil signature.asc
« previous php.internals (#38680) next »