Re: [RFC][VOTE] Closure from callable

From: Date: Mon, 16 May 2016 08:40:42 +0000
Subject: Re: [RFC][VOTE] Closure from callable
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-93351@lists.php.net to get a copy of this message
On Mon, 16 May 2016 03:56:38 +0300, Sara Golemon <pollita@php.net> wrote:
On Sun, May 15, 2016 at 11:20 AM, Nikita Nefedov <inefedor@gmail.com> wrote:
why would you need to support a $this->fieldName case though?
Because to not support it would be to deliberately design in a new flavor of inconsistency into the language. $obj->memb is a property access in PHP. Making it suddenly mean "method" is a significant change (and one which belongs in a major version if at all). -Sara
The whole idea is not in the syntax here, but in the notion that this access can only be static (so there'd be no way to do $cb = [$this, "methodName"]; callable($cb) - you'd have to call Closure::fromCallable($cb) instead). If you don't like the fact that $obj->methodName looks like a field access then there are ways around this. Because we still need a static way of exporting function references (whether it'd be as a closure or array). Other proposals were using $obj->method::FUNCTION syntax or something similar for example...

« previous php.internals (#93351) next »