Re: PHP Array Literals

From: Date: Fri, 03 Feb 2006 02:24:35 +0000
Subject: Re: PHP Array Literals
References: 1 2 3 4 5 6 7 8 9 10  Groups: php.internals 
Request: Send a blank email to internals+get-21778@lists.php.net to get a copy of this message
So, all I heard as reasons not to introduce the '[]' syntax for creating arrays is because "'array()' is perfectly fine" and that it wouldn't make sense to have two syntaxes (compared to other legacy stuff in PHP). And certainly nobody has an objection to the fact that developers have to learn that []s are used in arrays for accessing indexes of an array, so why would it be a problem to learn at the same time that arrays could be created with the same []s? Sane people will see ["foo", "bar"] and say "wow, that looks like a list. That must be a list!" I see array("foo", "bar") and I say "wow, why am I calling a function to create something so basic as an array?" (Though, admittedly it is not a function – it does, however, appear to be one.) So, if you do have problems with array literals using the [] syntax, please, do you mind expressing them here? I understand you gave rebuttals, but nothing particularly similar to simple arguments against it. M.T.

« previous php.internals (#21778) next »