Re: [PHP-DEV] [RFC] Short Closures 2, aka auto-capture take 3

2022-07-01 Thread Arnaud Le Blanc
Hi Björn, On Wed, Jun 29, 2022 at 8:09 PM Björn Larsson via internals < internals@lists.php.net> wrote: > Would it be an option to include a "Future scope" with the features: > - Explicit capture that list only the variables to be captured by value > or reference, nothing else. > - Extending the

Re: [PHP-DEV] [RFC] Short Closures 2, aka auto-capture take 3

2022-07-01 Thread Arnaud Le Blanc
Hi Rowan, Since this still has a small chance of breaking existing code, we preferred to exclude arrow functions from this change, for now. We have added this in Future Scope. This is something we could do in a follow-up RFC. Regards,

Re: [PHP-DEV] [RFC] Short Closures 2, aka auto-capture take 3

2022-07-01 Thread Arnaud Le Blanc
Hi Guilliam, Thank you for noticing. The PR is now fully in sync with the RFC (no arrow function changes, no explicit use support). The RFC also now clarifies that arrow functions are not changed by the RFC.

Re: [PHP-DEV] [RFC] Short Closures 2, aka auto-capture take 3

2022-07-01 Thread Guilliam Xavier
On Thu, Jun 30, 2022 at 7:37 PM Arnaud Le Blanc wrote: > > On jeudi 30 juin 2022 18:29:44 CEST Guilliam Xavier wrote: > > Ah? Sorry, I had interpreted > > https://github.com/php/php-src/pull/8330/files#diff-85701127596aca0e597bd796 > > 1b5d59cdde4f6bb3e2a109a22be859ab7568b4d2R7318-R7320 as

Re: [PHP-DEV] [RFC] Short Closures 2, aka auto-capture take 3

2022-06-30 Thread Rowan Tommins
On 30/06/2022 18:37, Arnaud Le Blanc wrote: On jeudi 30 juin 2022 18:29:44 CEST Guilliam Xavier wrote: Ah? Sorry, I had interpreted https://github.com/php/php-src/pull/8330/files#diff-85701127596aca0e597bd796 1b5d59cdde4f6bb3e2a109a22be859ab7568b4d2R7318-R7320 as "capture the *minimal* set of

Re: [PHP-DEV] [RFC] Short Closures 2, aka auto-capture take 3

2022-06-30 Thread Arnaud Le Blanc
On jeudi 30 juin 2022 18:29:44 CEST Guilliam Xavier wrote: > Ah? Sorry, I had interpreted > https://github.com/php/php-src/pull/8330/files#diff-85701127596aca0e597bd796 > 1b5d59cdde4f6bb3e2a109a22be859ab7568b4d2R7318-R7320 as "capture the > *minimal* set of variables for *both* arrow functions and

Re: [PHP-DEV] [RFC] Short Closures 2, aka auto-capture take 3

2022-06-30 Thread Guilliam Xavier
On Thu, Jun 30, 2022 at 5:57 PM Arnaud Le Blanc wrote: > > Hi, > > On jeudi 30 juin 2022 16:18:44 CEST Robert Landers wrote: > > Are > > optimizations going to be applied to single-line arrow functions (I > > didn't see that in the RFC, but I admittedly didn't look that hard and > > I vaguely

Re: [PHP-DEV] [RFC] Short Closures 2, aka auto-capture take 3

2022-06-30 Thread Robert Landers
On Thu, Jun 30, 2022 at 5:47 PM Guilliam Xavier wrote: > > On Thu, Jun 30, 2022 at 3:26 PM Dan Ackroyd wrote: > > > > Hi Rowan, > > > > Rowan wrote: > > > For that to work, it would require the variable to be captured by > > > reference, not value. > > > ... > > > The only way for it to work

Re: [PHP-DEV] [RFC] Short Closures 2, aka auto-capture take 3

2022-06-30 Thread Arnaud Le Blanc
Hi, On jeudi 30 juin 2022 16:18:44 CEST Robert Landers wrote: > Are > optimizations going to be applied to single-line arrow functions (I > didn't see that in the RFC, but I admittedly didn't look that hard and > I vaguely remember reading something about it in one of these > threads)? If so, it

Re: [PHP-DEV] [RFC] Short Closures 2, aka auto-capture take 3

2022-06-30 Thread Guilliam Xavier
On Thu, Jun 30, 2022 at 3:26 PM Dan Ackroyd wrote: > > Hi Rowan, > > Rowan wrote: > > For that to work, it would require the variable to be captured by > > reference, not value. > > ... > > The only way for it to work would be using capture by reference (not > > supported by the proposed short

Re: [PHP-DEV] [RFC] Short Closures 2, aka auto-capture take 3

2022-06-30 Thread Rowan Tommins
On 30/06/2022 14:25, Dan Ackroyd wrote: With automatic capturing of variables, for the code example I gave the user would want the variable to be captured, and to them it looks like it should be, but because of an optimization it is not. Please look again at the detailed explanation I gave,

Re: [PHP-DEV] [RFC] Short Closures 2, aka auto-capture take 3

2022-06-30 Thread Robert Landers
On Thu, Jun 30, 2022 at 3:26 PM Dan Ackroyd wrote: > > Hi Rowan, > > Rowan wrote: > > For that to work, it would require the variable to be captured by > > reference, not value. > > ... > > The only way for it to work would be using capture by reference (not > > supported by the proposed short

Re: [PHP-DEV] [RFC] Short Closures 2, aka auto-capture take 3

2022-06-30 Thread Dan Ackroyd
Hi Rowan, Rowan wrote: > For that to work, it would require the variable to be captured by > reference, not value. > ... > The only way for it to work would be using capture by reference (not > supported by the proposed short syntax): I wrote about this before. Some of the words in the RFC are,

Re: [PHP-DEV] [RFC] Short Closures 2, aka auto-capture take 3

2022-06-30 Thread Rowan Tommins
On 30/06/2022 11:29, Arnaud Le Blanc wrote: I feel that the RAII pattern aka SBRM / Scope-Bound Resource Management is not relevant in PHP context, and I don't believe that it's commonly used in PHP or in garbage collected language. I've used a simple version of the pattern effectively to

Re: [PHP-DEV] [RFC] Short Closures 2, aka auto-capture take 3

2022-06-30 Thread Arnaud Le Blanc
Hi, On jeudi 30 juin 2022 00:31:44 CEST Dan Ackroyd wrote: > On Wed, 29 Jun 2022 at 18:30, Larry Garfield wrote: > > The conversation has died down, so we'll be opening the vote for this > > tomorrow. > I think I've just thought of a problem with the optimization bit of > 'not capturing

Re: [PHP-DEV] [RFC] Short Closures 2, aka auto-capture take 3

2022-06-30 Thread Guilliam Xavier
On Thu, Jun 30, 2022 at 11:20 AM Robert Landers wrote: > > On Thu, Jun 30, 2022 at 10:19 AM Rowan Tommins > wrote: > > > > On 29/06/2022 23:31, Dan Ackroyd wrote: > > > Imagine some code that looks like this: > > > > > > // Acquire some resource e.g. an exclusive lock. > > > $some_resource =

Re: [PHP-DEV] [RFC] Short Closures 2, aka auto-capture take 3

2022-06-30 Thread Rowan Tommins
On 30/06/2022 10:20, Robert Landers wrote: I think their suggested code would work (at least currently in PHP) by the simple fact they would increase the reference count on that object/resource until they set it as null. However, with the "optimization," the reference count will never be

Re: [PHP-DEV] [RFC] Short Closures 2, aka auto-capture take 3

2022-06-30 Thread Robert Landers
On Thu, Jun 30, 2022 at 10:19 AM Rowan Tommins wrote: > > On 29/06/2022 23:31, Dan Ackroyd wrote: > > Imagine some code that looks like this: > > > > // Acquire some resource e.g. an exclusive lock. > > $some_resource = acquire_some_resource(); > > > > $fn = fn () { > > // Free that resource

Re: [PHP-DEV] [RFC] Short Closures 2, aka auto-capture take 3

2022-06-30 Thread Rowan Tommins
On 29/06/2022 23:31, Dan Ackroyd wrote: Imagine some code that looks like this: // Acquire some resource e.g. an exclusive lock. $some_resource = acquire_some_resource(); $fn = fn () { // Free that resource $some_resource = null; } // do some stuff that assumes the exclusive // lock

Re: [PHP-DEV] [RFC] Short Closures 2, aka auto-capture take 3

2022-06-29 Thread Dan Ackroyd
On Wed, 29 Jun 2022 at 18:30, Larry Garfield wrote: > > The conversation has died down, so we'll be opening the vote for this > tomorrow. I think I've just thought of a problem with the optimization bit of 'not capturing variables if they are written to before being used inside the closure'.

Re: [PHP-DEV] [RFC] Short Closures 2, aka auto-capture take 3

2022-06-29 Thread Björn Larsson via internals
Den 2022-06-29 kl. 19:30, skrev Larry Garfield: On Thu, Jun 9, 2022, at 11:34 AM, Larry Garfield wrote: Last year, Nuno Maduro and I put together an RFC for combining the multi-line capabilities of long-closures with the auto-capture compactness of short-closures. That RFC didn't fully go to

Re: [PHP-DEV] [RFC] Short Closures 2, aka auto-capture take 3

2022-06-29 Thread Larry Garfield
On Thu, Jun 9, 2022, at 11:34 AM, Larry Garfield wrote: > Last year, Nuno Maduro and I put together an RFC for combining the > multi-line capabilities of long-closures with the auto-capture > compactness of short-closures. That RFC didn't fully go to completion > due to concerns over the

Re: [PHP-DEV] [RFC] Short Closures 2, aka auto-capture take 3

2022-06-15 Thread Larry Garfield
On Wed, Jun 15, 2022, at 7:05 AM, Guilliam Xavier wrote: >> > > Because variables are captured by-value, Short Closures can not have >> > > unintended side effects. >> > >> > Those statements are true for scalar values. They are not true for objects: >> >> This is shown in the "No unintended

Re: [PHP-DEV] [RFC] Short Closures 2, aka auto-capture take 3

2022-06-15 Thread Guilliam Xavier
> > > Because variables are captured by-value, Short Closures can not have > > > unintended side effects. > > > > Those statements are true for scalar values. They are not true for objects: > > This is shown in the "No unintended side-effects" section of the RFC. I'm confused by the last example:

Re: [PHP-DEV] [RFC] Short Closures 2, aka auto-capture take 3

2022-06-14 Thread Björn Larsson via internals
Den 2022-06-13 kl. 14:57, skrev Arnaud Le Blanc: On samedi 11 juin 2022 23:14:28 CEST Rowan Tommins wrote: My main concern is summed up accidentally by your choice of subject line for this thread: is the proposal to add *short closure syntax* or is it to add *auto-capturing closures*? The

Re: [PHP-DEV] [RFC] Short Closures 2, aka auto-capture take 3

2022-06-14 Thread Rowan Tommins
(Sorry for double reply, hit send too soon) On 14/06/2022 12:18, Arnaud Le Blanc wrote: Your example uses isset(), which is valid code in most circumstances, but as you said it's not particularly good code. Do you have other examples that come to mind ? There is plenty of code out there in

Re: [PHP-DEV] [RFC] Short Closures 2, aka auto-capture take 3

2022-06-14 Thread Rowan Tommins
On 14/06/2022 12:18, Arnaud Le Blanc wrote: - The closure mutates a value accessed through a captured variable. Mutable values include objects and resources, but NOT scalars or arrays (since they are copy-on-write). It's not something that is used very often, so is often forgotten or

Re: [PHP-DEV] [RFC] Short Closures 2, aka auto-capture take 3

2022-06-14 Thread Mike Schinkel
> On Jun 13, 2022, at 1:39 PM, Rowan Tommins wrote: > > On 13/06/2022 14:52, Larry Garfield wrote: >>> That's one perspective. The other perspective is that the proposal is to >>> extend closure syntax to support automatic capture. >> As noted before, this is a distinction without a

Re: [PHP-DEV] [RFC] Short Closures 2, aka auto-capture take 3

2022-06-14 Thread Arnaud Le Blanc
On lundi 13 juin 2022 15:36:26 CEST Rowan Tommins wrote: > > Auto-capture in PHP is by-value. This makes this impossible. It also makes > > explicit declarations non-necessary and much less useful. > > > > Live-variable analysis is mentioned in as part of implementation details. > > It should not

Re: [PHP-DEV] [RFC] Short Closures 2, aka auto-capture take 3

2022-06-14 Thread Arnaud Le Blanc
Hi Dan, On lundi 13 juin 2022 19:49:10 CEST Dan Ackroyd wrote: > > Auto-capture in PHP is by-value. This makes this impossible. It also makes > > explicit declarations non-necessary and much less useful. > > Separating off some pedantism from the hopefully constructive comment, > > I think some

Re: [PHP-DEV] [RFC] Short Closures 2, aka auto-capture take 3

2022-06-13 Thread Dan Ackroyd
Hi Larry, Arnaud, On Mon, 13 Jun 2022 at 13:57, Arnaud Le Blanc wrote: > > Auto-capture in PHP is by-value. This makes this impossible. It also makes > explicit declarations non-necessary and much less useful. > Separating off some pedantism from the hopefully constructive comment, I think

Re: [PHP-DEV] [RFC] Short Closures 2, aka auto-capture take 3

2022-06-13 Thread Rowan Tommins
On 13/06/2022 14:52, Larry Garfield wrote: That's one perspective. The other perspective is that the proposal is to extend closure syntax to support automatic capture. As noted before, this is a distinction without a difference. It's a difference in focus which is very evident in some of the

Re: [PHP-DEV] [RFC] Short Closures 2, aka auto-capture take 3

2022-06-13 Thread Dan Ackroyd
Hi Arnaud, Arnaud Le Blanc wrote: > > Following your comment, I have clarified a few things in the "Auto-capture > semantics" section. This includes a list of way in which these effects can be > observed. These are really marginal cases that are not relevant for most > programs. Cool, thanks.

Re: [PHP-DEV] [RFC] Short Closures 2, aka auto-capture take 3

2022-06-13 Thread Larry Garfield
On Mon, Jun 13, 2022, at 8:36 AM, Rowan Tommins wrote: > On 13/06/2022 13:57, Arnaud Le Blanc wrote: >> The proposal is to extend the Arrow Functions syntax so that it allows >> multiple statements. > > > That's one perspective. The other perspective is that the proposal is to > extend closure

Re: [PHP-DEV] [RFC] Short Closures 2, aka auto-capture take 3

2022-06-13 Thread Rowan Tommins
On 13/06/2022 13:57, Arnaud Le Blanc wrote: The proposal is to extend the Arrow Functions syntax so that it allows multiple statements. That's one perspective. The other perspective is that the proposal is to extend closure syntax to support automatic capture. Currently the `use()`

Re: [PHP-DEV] [RFC] Short Closures 2, aka auto-capture take 3

2022-06-13 Thread Rowan Tommins
On 13/06/2022 13:29, Arnaud Le Blanc wrote: Following your comment, I have clarified a few things in the "Auto-capture semantics" section. This includes a list of way in which these effects can be observed. These are really marginal cases that are not relevant for most programs. I'm not sure

Re: [PHP-DEV] [RFC] Short Closures 2, aka auto-capture take 3

2022-06-13 Thread Arnaud Le Blanc
On samedi 11 juin 2022 23:14:28 CEST Rowan Tommins wrote: > My main concern is summed up accidentally by your choice of subject line > for this thread: is the proposal to add *short closure syntax* or is it > to add *auto-capturing closures*? The proposal is to extend the Arrow Functions syntax

Re: [PHP-DEV] [RFC] Short Closures 2, aka auto-capture take 3

2022-06-13 Thread Arnaud Le Blanc
On dimanche 12 juin 2022 20:05:02 CEST Dan Ackroyd wrote: > On Thu, 9 Jun 2022 at 17:34, Larry Garfield wrote: > > That RFC didn't fully go to completion due to concerns over the > > performance impact > I don't believe that is an accurate summary. There were subtle issues > in the previous RFC

Re: [PHP-DEV] [RFC] Short Closures 2, aka auto-capture take 3

2022-06-13 Thread Arnaud Le Blanc
On lundi 13 juin 2022 12:28:17 CEST Robert Landers wrote: > From a maintainer and code review aspect, I prefer the longer syntax > because it is 100% clear on which variables are being closed over and > utilized in the anonymous function. fn($x) => $x + $y is pretty clear > that $y is being pulled

Re: [PHP-DEV] [RFC] Short Closures 2, aka auto-capture take 3

2022-06-13 Thread Robert Landers
On Mon, Jun 13, 2022 at 11:36 AM Arnaud Le Blanc wrote: > > On dimanche 12 juin 2022 19:54:06 CEST Mark Baker wrote: > > Did many of those closures use "pass by reference" in the use clause, > > because that's one real differentiator between traditional closures and > > short lambdas. There's

Re: [PHP-DEV] [RFC] Short Closures 2, aka auto-capture take 3

2022-06-13 Thread Arnaud Le Blanc
On dimanche 12 juin 2022 19:54:06 CEST Mark Baker wrote: > Did many of those closures use "pass by reference" in the use clause, > because that's one real differentiator between traditional closures and > short lambdas. There's also the fact that use values are bound at the > point where the

Re: [PHP-DEV] [RFC] Short Closures 2, aka auto-capture take 3

2022-06-12 Thread Larry Garfield
On Sun, Jun 12, 2022, at 3:44 PM, Rowan Tommins wrote: > On 12/06/2022 18:21, Larry Garfield wrote: >> The primary target of this RFC is people writing 2-4 line closures that >> import 1-2 variables > > > The first half of that sentence I was expecting - although as I've > already said, I think

Re: [PHP-DEV] [RFC] Short Closures 2, aka auto-capture take 3

2022-06-12 Thread Rowan Tommins
On 12/06/2022 18:21, Larry Garfield wrote: The primary target of this RFC is people writing 2-4 line closures that import 1-2 variables The first half of that sentence I was expecting - although as I've already said, I think the chosen syntax suggests strongly that the RFC is really

Re: [PHP-DEV] [RFC] Short Closures 2, aka auto-capture take 3

2022-06-12 Thread Larry Garfield
On Sun, Jun 12, 2022, at 12:54 PM, Mark Baker wrote: > On 12/06/2022 19:21, Larry Garfield wrote: >> On Thu, Jun 9, 2022, at 11:34 AM, Larry Garfield wrote: >> >> A little data: >> >> I used Nikita's project analyzer on the top 1000 projects to get a rough >> sense of how long-closures are used

Re: [PHP-DEV] [RFC] Short Closures 2, aka auto-capture take 3

2022-06-12 Thread Deleu
On Sun, Jun 12, 2022 at 6:55 PM Rowan Tommins wrote: > > >It seems to me that you agree that there is a chance the proposed syntax > is > >going to be perceived as better and people will not want to use the old > >syntax anymore and that makes you not want to accept the RFC. > > No, it makes me

Re: [PHP-DEV] [RFC] Short Closures 2, aka auto-capture take 3

2022-06-12 Thread Dan Ackroyd
On Thu, 9 Jun 2022 at 17:34, Larry Garfield wrote: > > That RFC didn't fully go to completion due to concerns over the performance > impact I don't believe that is an accurate summary. There were subtle issues in the previous RFC that should have been addressed. Nikita Popov wrote in

Re: [PHP-DEV] [RFC] Short Closures 2, aka auto-capture take 3

2022-06-12 Thread Mark Baker
On 12/06/2022 19:21, Larry Garfield wrote: On Thu, Jun 9, 2022, at 11:34 AM, Larry Garfield wrote: A little data: I used Nikita's project analyzer on the top 1000 projects to get a rough sense of how long-closures are used now. All usual caveats apply about such survey data. I was

Re: [PHP-DEV] [RFC] Short Closures 2, aka auto-capture take 3

2022-06-12 Thread Larry Garfield
On Thu, Jun 9, 2022, at 11:34 AM, Larry Garfield wrote: > Last year, Nuno Maduro and I put together an RFC for combining the > multi-line capabilities of long-closures with the auto-capture > compactness of short-closures. That RFC didn't fully go to completion > due to concerns over the

Re: [PHP-DEV] [RFC] Short Closures 2, aka auto-capture take 3

2022-06-12 Thread Rowan Tommins
On 12 June 2022 16:22:15 BST, Deleu wrote: >> I honestly don't think this is how it will be perceived. If this syntax >> is approved, people will see "fn" as the "new, better way" and >> "function" as the "old, annoying way". >> > >And to me that's not an argument to deny what people want. I

Re: [PHP-DEV] [RFC] Short Closures 2, aka auto-capture take 3

2022-06-12 Thread Deleu
On Sun, Jun 12, 2022 at 2:29 PM Rowan Tommins wrote: > On 11/06/2022 23:01, Deleu wrote: > > The RFC does mention that the existing Anonymous Function Syntax > > remains untouched and will not be deprecated. Whether the new syntax > > is better for nearly all closures will be a personal choice.

Re: [PHP-DEV] [RFC] Short Closures 2, aka auto-capture take 3

2022-06-12 Thread Rowan Tommins
On 12/06/2022 03:01, Larry Garfield wrote: ... users don't "learn to recognize" that a loop doesn't hide all variables from the parent scope; it would be very peculiar if it did. There are languages that do, however. Some languages have block-scoped variables by default (such as Rust), or

Re: [PHP-DEV] [RFC] Short Closures 2, aka auto-capture take 3

2022-06-12 Thread Rowan Tommins
On 11/06/2022 23:01, Deleu wrote: The RFC does mention that the existing Anonymous Function Syntax remains untouched and will not be deprecated. Whether the new syntax is better for nearly all closures will be a personal choice. I honestly don't think this is how it will be perceived. If

Re: [PHP-DEV] [RFC] Short Closures 2, aka auto-capture take 3

2022-06-12 Thread MKS Archive
> On Jun 11, 2022, at 10:01 PM, Larry Garfield wrote: > > On Sat, Jun 11, 2022, at 4:14 PM, Rowan Tommins wrote: >> On 09/06/2022 17:34, Larry Garfield wrote: >>> Last year, Nuno Maduro and I put together an RFC for combining the >>> multi-line capabilities of long-closures with the

Re: [PHP-DEV] [RFC] Short Closures 2, aka auto-capture take 3

2022-06-11 Thread Larry Garfield
On Sat, Jun 11, 2022, at 4:14 PM, Rowan Tommins wrote: > On 09/06/2022 17:34, Larry Garfield wrote: >> Last year, Nuno Maduro and I put together an RFC for combining the >> multi-line capabilities of long-closures with the auto-capture compactness >> of short-closures ... Arnaud Le Blanc has now

Re: [PHP-DEV] [RFC] Short Closures 2, aka auto-capture take 3

2022-06-11 Thread Larry Garfield
On Sat, Jun 11, 2022, at 5:01 PM, Deleu wrote: > On Sat, Jun 11, 2022 at 11:14 PM Rowan Tommins > wrote: > >> On 09/06/2022 17:34, Larry Garfield wrote: >> > Last year, Nuno Maduro and I put together an RFC for combining the >> multi-line capabilities of long-closures with the auto-capture

Re: [PHP-DEV] [RFC] Short Closures 2, aka auto-capture take 3

2022-06-11 Thread Deleu
On Sat, Jun 11, 2022 at 11:14 PM Rowan Tommins wrote: > On 09/06/2022 17:34, Larry Garfield wrote: > > Last year, Nuno Maduro and I put together an RFC for combining the > multi-line capabilities of long-closures with the auto-capture compactness > of short-closures ... Arnaud Le Blanc has now

Re: [PHP-DEV] [RFC] Short Closures 2, aka auto-capture take 3

2022-06-11 Thread Rowan Tommins
On 09/06/2022 17:34, Larry Garfield wrote: Last year, Nuno Maduro and I put together an RFC for combining the multi-line capabilities of long-closures with the auto-capture compactness of short-closures ... Arnaud Le Blanc has now picked up the flag with an improved implementation ... The RFC

Re: [PHP-DEV] [RFC] Short Closures 2, aka auto-capture take 3

2022-06-09 Thread Nikita Popov
On Thu, Jun 9, 2022 at 9:39 PM Marco Pivetta wrote: > Hey Nikita, > > On Thu, 9 Jun 2022 at 21:35, Nikita Popov wrote: > >> On Thu, Jun 9, 2022 at 9:29 PM Marco Pivetta wrote: >> >>> >>> On Thu, 9 Jun 2022 at 21:27, Nikita Popov wrote: >>> On Thu, Jun 9, 2022 at 8:15 PM Arnaud Le Blanc

Re: [PHP-DEV] [RFC] Short Closures 2, aka auto-capture take 3

2022-06-09 Thread Marco Pivetta
Hey Nikita, On Thu, 9 Jun 2022 at 21:35, Nikita Popov wrote: > On Thu, Jun 9, 2022 at 9:29 PM Marco Pivetta wrote: > >> >> On Thu, 9 Jun 2022 at 21:27, Nikita Popov wrote: >> >>> On Thu, Jun 9, 2022 at 8:15 PM Arnaud Le Blanc >>> wrote: >>> > Would that allow us to get rid of `static fn

Re: [PHP-DEV] [RFC] Short Closures 2, aka auto-capture take 3

2022-06-09 Thread Nikita Popov
On Thu, Jun 9, 2022 at 9:29 PM Marco Pivetta wrote: > > On Thu, 9 Jun 2022 at 21:27, Nikita Popov wrote: > >> On Thu, Jun 9, 2022 at 8:15 PM Arnaud Le Blanc >> wrote: >> >>> Hi, >>> >>> On jeudi 9 juin 2022 18:46:53 CEST Marco Pivetta wrote: >>> > ## nesting these functions within each other

Re: [PHP-DEV] [RFC] Short Closures 2, aka auto-capture take 3

2022-06-09 Thread Marco Pivetta
On Thu, 9 Jun 2022 at 21:27, Nikita Popov wrote: > On Thu, Jun 9, 2022 at 8:15 PM Arnaud Le Blanc > wrote: > >> Hi, >> >> On jeudi 9 juin 2022 18:46:53 CEST Marco Pivetta wrote: >> > ## nesting these functions within each other >> > >> > What happens when/if we nest these functions? Take this

Re: [PHP-DEV] [RFC] Short Closures 2, aka auto-capture take 3

2022-06-09 Thread Nikita Popov
On Thu, Jun 9, 2022 at 8:15 PM Arnaud Le Blanc wrote: > Hi, > > On jeudi 9 juin 2022 18:46:53 CEST Marco Pivetta wrote: > > ## nesting these functions within each other > > > > What happens when/if we nest these functions? Take this minimal example: > > > > ```php > > $a = 'hello world'; > > > >

Re: [PHP-DEV] [RFC] Short Closures 2, aka auto-capture take 3

2022-06-09 Thread Larry Garfield
On Thu, Jun 9, 2022, at 1:36 PM, Michał Marcin Brzuchalski wrote: > Hi Larry, > > czw., 9 cze 2022 o 18:34 Larry Garfield napisał(a): > >> Last year, Nuno Maduro and I put together an RFC for combining the >> multi-line capabilities of long-closures with the auto-capture compactness >> of

Re: [PHP-DEV] [RFC] Short Closures 2, aka auto-capture take 3

2022-06-09 Thread Michał Marcin Brzuchalski
Hi Larry, czw., 9 cze 2022 o 18:34 Larry Garfield napisał(a): > Last year, Nuno Maduro and I put together an RFC for combining the > multi-line capabilities of long-closures with the auto-capture compactness > of short-closures. That RFC didn't fully go to completion due to concerns > over the

Re: [PHP-DEV] [RFC] Short Closures 2, aka auto-capture take 3

2022-06-09 Thread Arnaud Le Blanc
Hi, On jeudi 9 juin 2022 18:46:53 CEST Marco Pivetta wrote: > ## nesting these functions within each other > > What happens when/if we nest these functions? Take this minimal example: > > ```php > $a = 'hello world'; > > (fn () { > (fn () { > echo $a; > })(); > })(); > ```

Re: [PHP-DEV] [RFC] Short Closures 2, aka auto-capture take 3

2022-06-09 Thread Marco Pivetta
Hey Larry, On Thu, 9 Jun 2022 at 18:34, Larry Garfield wrote: > Last year, Nuno Maduro and I put together an RFC for combining the > multi-line capabilities of long-closures with the auto-capture compactness > of short-closures. That RFC didn't fully go to completion due to concerns > over