RFC proposal for alternative list syntax

php.internals

Julian Rhind

10 years ago
Hi   I have a proposal for new alternative syntax for list   // In the old days we did this   list ($a, $b) = array (1, 2);   // With the new array syntax this has been improved to   list ($a, $b) = [1, 2];   // I think this new syntax should logically extend to   [$a, $b] = [1, 2];   Regards   Julian   Julian Rhind

Martin Keckeis

10 years ago
Am 27.12.2015 9:00 nachm. schrieb "Julian Rhind" <julianrhind@outlook.com>:
> > Hi > > I have a proposal for new alternative syntax for list > > // In the old days we did this > > list ($a, $b) = array (1, 2); > > // With the new array syntax this has been improved to > > list ($a, $b) = [1, 2]; > > // I think this new syntax should logically extend to > > [$a, $b] = [1, 2]; > > Regards > > Julian > > Julian Rhind > > > > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http:// <http://www.php.net/unsub.php>www.php.net
<http://www.php.net/unsub.php>/ <http://www.php.net/unsub.php>unsub.php <http://www.php.net/unsub.php>
>
It looks nice. I like it

Stas Malyshev

10 years ago
Hi!
> // With the new array syntax this has been improved to > > list ($a, $b) = [1, 2]; > > // I think this new syntax should logically extend to > > [$a, $b] = [1, 2];
list() and array() are two different language constructs, using the same syntax for them is a bad idea.
-- Stas Malyshev smalyshev@gmail.com

Alain Williams

10 years ago
On Sun, Dec 27, 2015 at 03:20:40PM -0800, Stanislav Malyshev wrote:
> Hi! > > > // With the new array syntax this has been improved to > > > > list ($a, $b) = [1, 2]; > > > > // I think this new syntax should logically extend to > > > > [$a, $b] = [1, 2]; > > list() and array() are two different language constructs, using the same > syntax for them is a bad idea.
What he wrote looks very perl-ish, but with [] instead of (). The perl ideom to swap the values of 2 variables: ($b, $a) = ($a, $b); could be written in PHP as: [$b, $a] = [$a, $b]; Looked at that way (left hand of '=' only) it is not that bad.
-- Alain Williams Linux/GNU Consultant - Mail systems, Web sites, Networking, Programmer, IT Lecturer. +44 (0) 787 668 0256 http://www.phcomp.co.uk/ Parliament Hill Computers Ltd. Registration Information: http://www.phcomp.co.uk/contact.php #include <std_disclaimer.h>

Robert Stoll

10 years ago
Hi,
> -----Ursprüngliche Nachricht----- > Von: Stanislav Malyshev [mailto:smalyshev@gmail.com] > Gesendet: Montag, 28. Dezember 2015 00:21 > An: Julian Rhind; internals@lists.php.net > Betreff: Re: [PHP-DEV] RFC proposal for alternative list syntax > > Hi! > > > // With the new array syntax this has been improved to > > > > list ($a, $b) = [1, 2]; > > > > // I think this new syntax should logically extend to > > > > [$a, $b] = [1, 2]; > > list() and array() are two different language constructs, using the same syntax for them is a bad idea. > > -- > Stas Malyshev > smalyshev@gmail.com > > -- > PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
To me it looks pretty much like pattern matching and I would like to see pattern matching in PHP. Maybe we need to add a little bit more syntax to distinguish it from normal array usage but I like the idea.

Pierre Joye

10 years ago
On Mon, Dec 28, 2015 at 6:20 AM, Stanislav Malyshev <smalyshev@gmail.com> wrote:
> Hi! > >> // With the new array syntax this has been improved to >> >> list ($a, $b) = [1, 2]; >> >> // I think this new syntax should logically extend to >> >> [$a, $b] = [1, 2]; > > list() and array() are two different language constructs, using the same > syntax for them is a bad idea.
I tend to agree here but it exists elsewhere and is quite handy. Also the behavior of this expression, in this case, is obvious. Cheers,
-- Pierre @pierrejoye | http://www.libgd.org

Kris Craig

10 years ago
On Dec 27, 2015 7:56 PM, "Pierre Joye" <pierre.php@gmail.com> wrote:
> > On Mon, Dec 28, 2015 at 6:20 AM, Stanislav Malyshev <smalyshev@gmail.com>
wrote:
> > Hi! > > > >> // With the new array syntax this has been improved to > >> > >> list ($a, $b) = [1, 2]; > >> > >> // I think this new syntax should logically extend to > >> > >> [$a, $b] = [1, 2]; > > > > list() and array() are two different language constructs, using the same > > syntax for them is a bad idea. > > I tend to agree here but it exists elsewhere and is quite handy. Also > the behavior of this expression, in this case, is obvious. > > > Cheers, > -- > Pierre > > @pierrejoye | http://www.libgd.org > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php >
This could be very nice shortcut to have. Seems intuitive enough; I doubt there'd be any serious confusion over this. You should draft an RFC for this, OP. --Kris

Julian Rhind

10 years ago
Hi Thanks all for the feedback - I'm posting back to get some "RFC karma" for my newly created wiki account please - so I can post my RFC - username is "julian" Thanks Regards Julian ________________________________ From: Kris Craig <kris.craig@gmail.com> Sent: 28 December 2015 18:40 To: Pierre Joye Cc: PHP internals list; Julian Rhind; Stanislav Malyshev Subject: Re: [PHP-DEV] RFC proposal for alternative list syntax On Dec 27, 2015 7:56 PM, "Pierre Joye" <pierre.php@gmail.com<mailto:pierre.php@gmail.com>> wrote:
> > On Mon, Dec 28, 2015 at 6:20 AM, Stanislav Malyshev <smalyshev@gmail.com<mailto:smalyshev@gmail.com>> wrote: > > Hi! > > > >> // With the new array syntax this has been improved to > >> > >> list ($a, $b) = [1, 2]; > >> > >> // I think this new syntax should logically extend to > >> > >> [$a, $b] = [1, 2]; > > > > list() and array() are two different language constructs, using the same > > syntax for them is a bad idea. > > I tend to agree here but it exists elsewhere and is quite handy. Also > the behavior of this expression, in this case, is obvious. > > > Cheers, > -- > Pierre > > @pierrejoye | http://www.libgd.org > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php >
This could be very nice shortcut to have. Seems intuitive enough; I doubt there'd be any serious confusion over this. You should draft an RFC for this, OP. --Kris

Julian Rhind

10 years ago
Hi Thanks all for the feedback - I'm posting back to get some "RFC karma" for my newly created wiki account please - so I can post my RFC - username is "julian" Thanks Regards Julian ________________________________ From: Kris Craig <kris.craig@gmail.com> Sent: 28 December 2015 18:40 To: Pierre Joye Cc: PHP internals list; Julian Rhind; Stanislav Malyshev Subject: Re: [PHP-DEV] RFC proposal for alternative list syntax On Dec 27, 2015 7:56 PM, "Pierre Joye" <pierre.php@gmail.com<mailto:pierre.php@gmail.com>> wrote:
> > On Mon, Dec 28, 2015 at 6:20 AM, Stanislav Malyshev <smalyshev@gmail.com<mailto:smalyshev@gmail.com>> wrote: > > Hi! > > > >> // With the new array syntax this has been improved to > >> > >> list ($a, $b) = [1, 2]; > >> > >> // I think this new syntax should logically extend to > >> > >> [$a, $b] = [1, 2]; > > > > list() and array() are two different language constructs, using the same > > syntax for them is a bad idea. > > I tend to agree here but it exists elsewhere and is quite handy. Also > the behavior of this expression, in this case, is obvious. > > > Cheers, > -- > Pierre > > @pierrejoye | http://www.libgd.org > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php >
This could be very nice shortcut to have. Seems intuitive enough; I doubt there'd be any serious confusion over this. You should draft an RFC for this, OP. --Kris

Julian Rhind

10 years ago
Hi Thanks all for the feedback - I'm posting back to get some "RFC karma" for my newly created wiki account please - so I can post my RFC - username is "julian" Thanks Regards Julian ________________________________ From: Kris Craig <kris.craig@gmail.com> Sent: 28 December 2015 18:40 To: Pierre Joye Cc: PHP internals list; Julian Rhind; Stanislav Malyshev Subject: Re: [PHP-DEV] RFC proposal for alternative list syntax On Dec 27, 2015 7:56 PM, "Pierre Joye" <pierre.php@gmail.com<mailto:pierre.php@gmail.com>> wrote:
> > On Mon, Dec 28, 2015 at 6:20 AM, Stanislav Malyshev <smalyshev@gmail.com<mailto:smalyshev@gmail.com>> wrote: > > Hi! > > > >> // With the new array syntax this has been improved to > >> > >> list ($a, $b) = [1, 2]; > >> > >> // I think this new syntax should logically extend to > >> > >> [$a, $b] = [1, 2]; > > > > list() and array() are two different language constructs, using the same > > syntax for them is a bad idea. > > I tend to agree here but it exists elsewhere and is quite handy. Also > the behavior of this expression, in this case, is obvious. > > > Cheers, > -- > Pierre > > @pierrejoye | http://www.libgd.org > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php >
This could be very nice shortcut to have. Seems intuitive enough; I doubt there'd be any serious confusion over this. You should draft an RFC for this, OP. --Kris

Ferenc Kovacs

10 years ago
On Fri, Jan 15, 2016 at 4:45 PM, Julian Rhind <julianrhind@outlook.com> wrote:
> Hi > > > Thanks all for the feedback - I'm posting back to get some "RFC karma" for > my newly created wiki account please - so I can post my RFC - username is > "julian" > > > Thanks > > > Regards > > > Julian > > >
hi Julian, I've just granted you rfc wiki karma, so you should be able to create/edit pages under the rfc namespace in the wiki.
-- Ferenc Kovács @Tyr43l - http://tyrael.hu

Alex Sky

10 years ago
It looks like, destructuring assignment, in ES6 https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment I like! )