On 20.10.2022 at 19:03, Rowan Tommins wrote:

> On 20/10/2022 17:48, David Rodrigues wrote:
>
>> Regarding this, in case you're literally saying that internally "fn()"
>> turns into a common "function", and getting back to the main topic,
>> would it be possible to do the same with compact()?
>>
>> fn() => compact('dummy')
>> turns into:
>> fn() => [ 'dummy' => $dummy ]
>> which turns into:
>> function() use($dummy) { return [ 'dummy' => $dummy ]; }
>
> Yes, that is what I meant by "it would be possible for the compiler to
> special-case this scenario";

Well, in the general case, the compiler cannot special-case this,
because compact() is a normal function, so might be used as "variable
function", or may not refer to the top-level compact() at all (the
called symbol may not be fully qualified).

> I explained why I think that would be a bad
> idea, and suggested an alternative.

ACK

--
Christoph M. Becker

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

Reply via email to