Re: Closures as methods (and Closure::bind)

From: Date: Wed, 11 Aug 2010 15:52:35 +0000
Subject: Re: Closures as methods (and Closure::bind)
References: 1 2 3 4  Groups: php.internals 
Request: Send a blank email to internals+get-49349@lists.php.net to get a copy of this message
On Wed, 11 Aug 2010 15:37:01 +0100, Johannes Schlüter <johannes@schlueters.de> wrote:
On Wed, 2010-08-11 at 15:29 +0100, Gustavo Lopes wrote:
      * What about allowing properties with function names as
strings or
        array($obj_or_class, 'method'), won't that be needed for
being
        consistent with local variables?
Well, you cannot do "$a = 'phpinfo'; $a();" as well, so it's consistent with that. I think what you refer to would only make sense if that were allowed. You can. This is valid. OK, I know where I got this idea. "$a = 'phpinfo'; $a();" is actually the only valid case. array callbacks or 'Foo::bar' are forbidden. In order to be called as instance methods, the closure properties needs to have a bound instance -- preferably -- very preferably -- the instance where the closure is stored. In this case, it doesn't make sense to allow 'function' to be called, because then we wouldn't have anything with which to fill the $this pointer. I guess it could make some sense for static calls, though. -- Gustavo Lopes

« previous php.internals (#49349) next »