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
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
--
To unsubscribe, visit: http:// http://www.php.net/unsub.phpwww.php.net
http://www.php.net/unsub.php/ http://www.php.net/unsub.phpunsub.php
http://www.php.net/unsub.php
It looks nice. I like it
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
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
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 syntaxHi!
// 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--
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.
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
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
--
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
It looks like, destructuring assignment, in ES6
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment
I like! )