Re: [RFC] First-class callable syntax
| From: | Aleksander Machniak | Date: | Thu, 20 May 2021 18:34:03 +0000 |
| Subject: | Re: [RFC] First-class callable syntax | ||
| References: | 1 2 3 4 5 6 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-114544@lists.php.net to get a copy of this message | ||
On 20.05.2021 19:05, Nikita Popov wrote:
>> $fn = &Foo::myFunc;
>>
> Unfortunately, this syntax is trivially ambiguous. "$fn = &$this->myFunc"
> is currently already interpreted as a reference assignment of the property
> $this->myFunc.
could that be just fn(sth)? I mean without the => part.
$fn = fn($this->myFunc);
$fn = fn(myFunc);
$fn = fn(Foo::myFunc);
and then something like this
$partial = fn(Foo::myFunc)[?, 42];
or
$partial = fn(Foo::myFunc, ?, 42);
My earlier idea was that actually cloning a callable could convert it to
a Closure, but I'm not sure now:
$fn = clone $this->myFunc;
or is this a heresy? ;)
--
Aleksander Machniak
Kolab Groupware Developer [https://kolab.org]
Roundcube Webmail Developer [https://roundcube.net]
----------------------------------------------------
PGP: 19359DC1 # Blog: https://kolabian.wordpress.com