Hello Etienne,

Saturday, August 2, 2008, 7:36:23 PM, you wrote:

> 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.

Actually it is the best time, well earlier would probably have been even
better. But seriously, the reason for an extended alpha phase is testing
and adjusting features if they do not behave as we like.

> 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..

Invokable sounds fine with me. It would be like Traversable. We don't
use Interfaces for much other stuff but imo we should.

> 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)

Of course not this must be fixed. After all we have invocation by
reflection with and without array. And this would be so badly inconsistent.
Which reminds me of writing a mail about the new inconsistencies in 5.3.


> 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




Best regards,
 Marcus


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

Reply via email to