Re: Syntactic improvement to array
| From: | Ilia Alshanetsky | Date: | Sun, 04 Feb 2007 17:48:45 +0000 |
| Subject: | Re: Syntactic improvement to array | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-27751@lists.php.net to get a copy of this message | ||
I personally find array extremely clear, in recent weeks I had to do A LOT of JavaScript work where the array syntax works in a manner you suggest for PHP and its a massive pain. It does not make for a very clear code. I think the syntax you propose is extremely confusing and we should stick to what we have right now.
On 4-Feb-07, at 12:39 PM, Andi Gutmans wrote:
I think it's actually more readable especially for people coming from other languages. I've always found the array() syntax not quite as readable as other languages because it allows for less structuring esp. with nesting. I actually find it harder to digest despite it being more verbose (which in most cases is not the case). It's definitely not about saving letters. I never favor saving typing unless there's a good reason. In this case I think it's just a better syntax which we should have used from day 1. AndiIlia Alshanetsky-----Original Message----- From: Ilia Alshanetsky [mailto:ilia@prohost.org] Sent: Sunday, February 04, 2007 9:28 AM To: Andi Gutmans Cc: internals@lists.php.net Subject: Re: [PHP-DEV] Syntactic improvement to array I have to second Marcus on this, this new syntax makes things harder to read. I mean what are you saving here, a few letter? Ilia On 4-Feb-07, at 2:25 AM, Andi Gutmans wrote:Hi, I thought I may have brought this up a long time ago butcouldn't findanything in the archives. For a long time already I've been thinking about possiblyadding a newsyntax for array(...) which would be shorter. I'd suggest[...]. WhileI am usually not in favor of having more than one way to dothings, Ithink it'd look much more elegant especially (but not only)for nestedarrays. So what I'm thinking of is: array(1, 2, 3) == [1, 2, 3] array(1, 2, array("foo", "bar")) == [1, 2, ["foo", "bar"]]array("key"=> 1, "key2" => 2) == ["key" => 1, "key2" => 2] $arr = [1, 2, 3] vs. $arr = array(1, 2, 3) Well enough examples given :) I think it's not worth doing unless there's overwhelming support as it's not desperately needed. But I'd be interested to hear people's thoughts. It seems implementation shouldn't be an issue butI'd haveto dive a bit deeper. Andi -- PHP Internals - PHP Runtime Development Mailing List Tounsubscribe,visit: http://www.php.net/unsub.phpIlia Alshanetsky