On Tue, Mar 14, 2023, at 10:28 PM, Alexandru Pătrănescu wrote:
> On Wed, Mar 15, 2023 at 1:09 AM Rowan Tommins <rowan.coll...@gmail.com>
> wrote:
>
>> On 14/03/2023 22:54, Larry Garfield wrote:
>>
>> Well, a large part of my resistance to automatic capture is that it
>> makes variable scope less visible at a glance. This avoids that by still
>> having a marker for "I am from another scope", but a much less verbose
>> one than the current use() clause.
>>
>
> How about first implementing use() for anonymous classes first?
> Something like:
>
> function foo(int $outer) {
>      return new class() use($outer) {
>          public function getIt() {
>              return $outer;
>          }
>      };
> }
>
> This would help with the main problem you expressed and be a less concern
> for the future.
>
> It's a different direction from what you suggested but it might be a lot
> harder to pass a $^ syntax or similar.
>
> Regards,
> Alex

For the record, while the auto-capture RFC[1] didn't reach a 2/3 majority to 
pass, it did have a strong majority support (62%).  Given that, I think it 
unlikely that a "require verbose manual capture in more places" proposal would 
fair that well.

[1] https://wiki.php.net/rfc/auto-capture-closure

--Larry Garfield

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

Reply via email to