Re: [PHP-DEV][RFC] Alternative "use" syntax for Closures

2019-06-17 Thread Ben Ramsey
> On Jun 17, 2019, at 12:50, Mark Randall wrote: > > On 17/06/2019 15:40, Ben Ramsey wrote: >>> Where "use (...)" would auto-capture all of the used variables in a similar >>> manner to short closures, that would certainly save a bit of time. > >> Would this mean that all variables in the

Re: [PHP-DEV][RFC] Alternative "use" syntax for Closures

2019-06-17 Thread Mark Randall
On 17/06/2019 15:40, Ben Ramsey wrote: Where "use (...)" would auto-capture all of the used variables in a similar manner to short closures, that would certainly save a bit of time. Would this mean that all variables in the “parent" are now available in the “child?” This seems like it could

Re: [PHP-DEV][RFC] Alternative "use" syntax for Closures

2019-06-17 Thread Rowan Collins
On Sat, 15 Jun 2019 at 23:22, Kalle Sommer Nielsen wrote: > The proposed syntax was also that of the proposed syntax when closures > arrived in 5.3 (and back then it was using the then keyword > 'lexical'), anyway. I believe the current syntax was chosen due to > scopes, as values are bound

Re: [PHP-DEV][RFC] Alternative "use" syntax for Closures

2019-06-17 Thread Ben Ramsey
> On Jun 16, 2019, at 07:04, Mark Randall wrote: > > On 15/06/2019 22:53, Wes wrote: >> Hello PHP, I just published >> https://wiki.php.net/rfc/alternative-closure-use-syntax >> I would love your opinion on this > > I'm not overly fond of it myself because I think it could make it slightly >

Re: [PHP-DEV][RFC] Alternative "use" syntax for Closures

2019-06-17 Thread Nikita Popov
On Sun, Jun 16, 2019 at 3:02 AM M. W. Moe wrote: > Hello, > > if you are upset; it's not the place here; your argument is efficiently > based on problems of indentation and handling commas > properly. > > Moreover, but not least, you have no idea what a lambda is; if we admit it > what you

Re: [PHP-DEV][RFC] Alternative "use" syntax for Closures

2019-06-17 Thread Benjamin Morel
> > ""M. W. Moe"" wrote > > If you do not accept any rational criticism; you should think of doing > > something else; I do not know; gardening maybe? who knows. > > > > P.S For my use of the "closure" you made a fool yourself beyond what you > > can grasp; but anyhow, my dear, it's refreshing,

Re: [PHP-DEV][RFC] Alternative "use" syntax for Closures

2019-06-17 Thread Mark Clements (HappyDog)
""M. W. Moe"" wrote in message news:CAHN63oOGX1E8n2_N7-m=vhytf7kxccpvlw3lokrotnzuzz-...@mail.gmail.com... > If you do not accept any rational criticism; you should think of doing > something else; I do not know; gardening maybe? who knows. > > P.S For my use of the "closure" you made a fool

Re: [PHP-DEV][RFC] Alternative "use" syntax for Closures

2019-06-16 Thread Markus Fischer
Hi, On 15.06.19 23:53, Wes wrote: https://wiki.php.net/rfc/alternative-closure-use-syntax Thanks for the RFC and effort, I know it seems overkill and wrong to have two different syntaxes for the same thing, but I really believe that's all we need to fix one of the most hated PHP syntax

Re: [PHP-DEV][RFC] Alternative "use" syntax for Closures

2019-06-16 Thread Wes
Hi Alexandru, I don't think there is intention to do that. In particular with pass by reference. Importing variables by-ref likely will be explicit, given recent discussions on the matter. The new Closures or the old ones might automatically "copy" all variables (by-value) at some point, but I

Re: [PHP-DEV][RFC] Alternative "use" syntax for Closures

2019-06-16 Thread Mark Randall
On 15/06/2019 22:53, Wes wrote: Hello PHP, I just published https://wiki.php.net/rfc/alternative-closure-use-syntax I would love your opinion on this I'm not overly fond of it myself because I think it could make it slightly more difficult to parse in my brain. If there was a: $x = 0; $y =

Re: [PHP-DEV][RFC] Alternative "use" syntax for Closures

2019-06-15 Thread Alexandru Pătrănescu
Hi, If at some point we would have multi-statement body arrow function, I would assume that one option would be to have the closure done automatically, as it is done now on the one-line arrow function. If the values will not be implicitly captured, maybe a new syntax to capture can be designed

Re: [PHP-DEV][RFC] Alternative "use" syntax for Closures

2019-06-15 Thread M. W. Moe
Hello, if you are upset; it's not the place here; your argument is efficiently based on problems of indentation and handling commas properly. Moreover, but not least, you have no idea what a lambda is; if we admit it what you propose; that is not feasible in PHP; why? because it would require a

Re: [PHP-DEV][RFC] Alternative "use" syntax for Closures

2019-06-15 Thread Kalle Sommer Nielsen
Den søn. 16. jun. 2019 kl. 02.48 skrev Wes : > > Hi Kalle. I hope it's feasible. Unfortunately I don't know much about > internals. Any info on the matter would be very appreciated, though :P > > Anyway, if we can scan the function body to complain about `return null;` > when the function is

Re: [PHP-DEV][RFC] Alternative "use" syntax for Closures

2019-06-15 Thread Wes
Hi Kalle. I hope it's feasible. Unfortunately I don't know much about internals. Any info on the matter would be very appreciated, though :P Anyway, if we can scan the function body to complain about `return null;` when the function is `:void`, surely we can scan just the very top of the function

Re: [PHP-DEV][RFC] Alternative "use" syntax for Closures

2019-06-15 Thread Wes
Welcome to the first inevitable patronizing message... No, my code is not smelly. If something is smelling for you, check your armpits. Importing 4 variables is not rare. If you think it's rare and should be done differently, maybe you should first actually do something with Closures before

Re: [PHP-DEV][RFC] Alternative "use" syntax for Closures

2019-06-15 Thread M. W. Moe
Hello, mostly, your argument in your rfc, is all about not finding a good syntax; hence your have a terrible coding style and you want to change the language for that. ``` $fn = function ( T1 $arg1_ , T1 $arg2_ , T1 $arg3_ , T1 $arg4_ , T1 $arg5_ , T1 $arg6_ ) use ($var1, &$var2, &$var3,

Re: [PHP-DEV][RFC] Alternative "use" syntax for Closures

2019-06-15 Thread Kalle Sommer Nielsen
Hi Den søn. 16. jun. 2019 kl. 01.37 skrev Wes : > > Hi Kalle, I realize it's going to be a bit odd when binding by value. But > it's not that hard to grasp. > > ``` > $a = 123; > $closure = function(){ > use $a; > echo $a; // 123 > }; > $a = 345; > ``` Take this example: function

Re: [PHP-DEV][RFC] Alternative "use" syntax for Closures

2019-06-15 Thread Wes
Hi Kalle, I realize it's going to be a bit odd when binding by value. But it's not that hard to grasp. ``` $a = 123; $closure = function(){ use $a; echo $a; // 123 }; $a = 345; ``` For this reason I specified it is mandatory to have `use` only at the very top (otherwise, it would

Re: [PHP-DEV][RFC] Alternative "use" syntax for Closures

2019-06-15 Thread Kalle Sommer Nielsen
Den søn. 16. jun. 2019 kl. 01.09 skrev Wes : > > Declaring variables or specifying which ones to import. Essentially it's > the same thing, so what gives? It's PHP's syntax, IMHO, that makes the > thing irritating to write :D The proposed syntax was also that of the proposed syntax when closures

Re: [PHP-DEV][RFC] Alternative "use" syntax for Closures

2019-06-15 Thread Marco Pivetta
On Sun, Jun 16, 2019, 00:09 Wes wrote: > Declaring variables or specifying which ones to import. Essentially it's > the same thing, so what gives? It's PHP's syntax, IMHO, that makes the > thing irritating to write :D > Just more AST to process, if you ask me  >

Re: [PHP-DEV][RFC] Alternative "use" syntax for Closures

2019-06-15 Thread Wes
Declaring variables or specifying which ones to import. Essentially it's the same thing, so what gives? It's PHP's syntax, IMHO, that makes the thing irritating to write :D

Re: [PHP-DEV][RFC] Alternative "use" syntax for Closures

2019-06-15 Thread G. P. B.
On Sat, 15 Jun 2019 at 23:57, Marco Pivetta wrote: > On Sat, Jun 15, 2019, 23:53 Wes wrote: > > > Hello PHP, I just published > > > > https://wiki.php.net/rfc/alternative-closure-use-syntax > > > > I would love your opinion on this > > > > I know it seems overkill and wrong to have two

Re: [PHP-DEV][RFC] Alternative "use" syntax for Closures

2019-06-15 Thread Marco Pivetta
Hey Wes, On Sat, Jun 15, 2019, 23:53 Wes wrote: > Hello PHP, I just published > > https://wiki.php.net/rfc/alternative-closure-use-syntax > > I would love your opinion on this > > I know it seems overkill and wrong to have two different syntaxes for the > same thing, but I really believe that's