RE: [PHP-DEV] Proposal: Array syntax
| From: | Steph | Date: | Wed, 05 Nov 2003 17:25:42 +0000 |
| Subject: | RE: [PHP-DEV] Proposal: Array syntax | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-5242@lists.php.net to get a copy of this message | ||
OK .. I'm a wobbler.
I think it would be cool to have the cleaner alternative syntax; I think I'd
use it *in some situations and not others*, and I think that that in itself
would make my code virtually unmaintainable by anyone else.
As Andi originally said, having more than one way to do things isn't always
a good thing.
Add me to the -1 list. Even tho' it's a cool idea.
- Steph
> -----Original Message-----
> From: Christian Schneider [mailto:cschneid@cschneid.com]
> Sent: 04 November 2003 23:33
> To: internals@lists.php.net
> Subject: [PHP-DEV] Proposal: Array syntax
>
>
> I propose to add an alternative (backward compatible) short array
> creation syntax:
> $a = [ 1, 2, 3 ]; and $a = [ 'a' => 42, 'b' => "foo" ];
>
> It can also be used in function calls:
> img(['src' => "logo.gif", 'alt' => "Logo"]);
>
> Reason behind this change: Arrays are used a lot and should therefore
> have as little syntactic overhead as possible. And I think the short
> syntax is also easier to read and write.
>
> A patch for the parser is trivial and is attached for Zend2.
>
> Note: I checked the newsgroup archive but couldn't find a discussion
> about this. After not hearing back about my proposed enhancement to
> debug_backtrace() and the dangling comma for function call parameters
> being rejected I wonder if I'm using the right mailing list for this :-)
>
> - Chris
>