Re: PATCH: anonymous functions in PHP

From: Date: Thu, 22 Mar 2007 18:00:26 +0000
Subject: Re: PATCH: anonymous functions in PHP
References: 1 2 3 4 5 6 7 8 9 10 11 12  Groups: php.internals 
Request: Send a blank email to internals+get-28556@lists.php.net to get a copy of this message
For the record, I do like this syntax, but it COULD be rewritten using current practices (see below).
That's a good point - actually most uses of closures could be with some effort rewritten as classes. The difference would be that in case of closures, closure chooses which parts of context to import, and in case of objects you would need to explicitly supply the parameters. Also, you'd have to explicitly call the object methods, can't just do $foo(). And of course it's not as slick and generic as closure - you'd have to write new class for each case.
class SortByKey implements Callable { ... $Sorter();
Well, you can do it now by using call_user_func(), and you also have advantage of using more than one function per class :) So I'm not sure it's necessary. -- Stanislav Malyshev, Zend Products Engineer stas@zend.com http://www.zend.com/

« previous php.internals (#28556) next »