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

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

Reply via email to