Re: [RFC] [DISCUSSION]: Closure from callable
| From: | Dan Ackroyd | Date: | Tue, 29 Sep 2015 15:12:21 +0000 |
| Subject: | Re: [RFC] [DISCUSSION]: Closure from callable | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-88552@lists.php.net to get a copy of this message | ||
On 29 September 2015 at 14:56, Peter Petermann <ppetermann80@gmail.com> wrote:
> why not just do "return function() { $this->myPrivateMethod(); };"
That would not work if there were any parameters to the function. Also
all other information would need to be duplicated e.g. the return
type.
> this should be easy enough to do userland, including checking if the method exists
It depends what you consider 'easy'. Here is an implementation
https://gist.github.com/Danack/27254e80b56bf477fd1f
As I said in the RFC, it does a significant chunk of work in userland,
including an exciting use of debug_backtrace to get the calling scope.
I am not sure it is actually a complete implemenation. I got tired of
writing it, and decided that it would be better implemented in PHP
core.
cheers
Dan