Re: [RFC] Auto-capture multi-line closures andshortfunctions take 2

From: Date: Thu, 25 Mar 2021 14:14:26 +0000
Subject: Re: [RFC] Auto-capture multi-line closures andshortfunctions take 2
References: 1 2 3 4 5 6 7 8 9 10 11  Groups: php.internals 
Request: Send a blank email to internals+get-113770@lists.php.net to get a copy of this message
> On Mar 25, 2021, at 9:54 AM, Olle Härstedt <olleharstedt@gmail.com> wrote:
> 
> 2021-03-25 14:29 GMT+01:00, Mark Randall <marandall@php.net>:
>> On 25/03/2021 09:28, Rowan Tommins wrote:
>>> That's not quite what I meant. I meant that you can't say "capture by
>>> default, but this variable is definitely local".
>> 
>> I think if there's one argument against, this would be it, but IMHO it
>> is a weakness in PHP as a whole.
>> 
>> The solution would be adding JS-like let / const statements. Which would
>> be a benefit to other things too.
> 
> JS does not support "definitely local". No language does, AFAIK.
> Unless you count value types.

Actually, at least a few languages on this list have "definitely local" variables:

https://en.wikipedia.org/wiki/List_of_programming_languages

I have had in-depth experience with two of them, the former of which was a dynamic language and both
support auto-capturing closures: 

- Clipper 
- GoLang

#fwiw


Thread (76 messages)

« previous php.internals (#113770) next »