Hi,

this is probably not the best time to raise concerns about __invoke
(closures) now that alpha1 is already realeased, but I believe it's
worth it.

1) I don't believe that having it thrown as another of those magic
method is a good idea. Rather, I'd like to have it represented by an
interface: Invokable. That way, type hints/checks can be done in user
land in a sane matter:

function foo(Invokable $obj) {
    $obj();
}

if ($foo instanceof Invokable) $foo();

etc..

2) Do we really want __invoke's argument to be mapped to caller
arguments. Providing an array of arguments, ala __call(Static) sounds
more consistent.
class A { public function __invoke($arg) {var_dump($arg); }} $a = new
A; $a(1,2); // int(1), currently. IMHO it should be array(1,2)


3) Do we really want to allow both static and non-static versions of __invoke ?
class A { public static function __invoke($args) { .. }} $a = new A;
$a(); being a static call to __invoke doesn't make much sense to me.


I hope these issues can be discussed and maybe addressed before a
final 5.3 release. I'm willing to do patches for all three concerns if
I sense a positive feeling towards this.

Regards,

-- 
Etienne Kneuss
http://www.colder.ch

Men never do evil so completely and cheerfully as
when they do it from a religious conviction.
-- Pascal

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to