Re: Array syntax []
| From: | Johannes Schlüter | Date: | Fri, 11 Jan 2008 10:54:24 +0000 |
| Subject: | Re: Array syntax [] | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-34692@lists.php.net to get a copy of this message | ||
Hi,
On Fri, 2008-01-11 at 12:40 +0300, Max Antonov wrote:
> I use PHP since version 5.0 release
> I'd like use this syntax
> $a = [ 2,6,9 ];
> $b = ['a'=>1 , 'v'=>'string'];
> foo(['bar'=>2, 'test'=null]);
The last line is exactly why I won't like such a syntax. Just consider
the a bit worse call like
foo([1, $a[2]]);
I might even construct worse examples, but in the end you'll have to
take a quite close look to see what's going on, whereas the array()
syntax directly tells you "hey, here's an array", it are just 5 letters,
so typing it isn't too hard (especially when using an editor with
completion) ...
Yes, it's nice in short code, but I think it makes it way harder to read
other people's code - and that's already hard enough. (I, myself, would,
of course, ( ;-) ) use it "right" but I tend to read more code than I
write)
johannes