Andi Gutmans schrieb:
Hi,I thought I may have brought this up a long time ago but couldn't find anything in the archives. For a long time already I've been thinking about possibly adding a new syntax for array(...) which would be shorter. I'd suggest [...]. While I am usually not in favor of having more than one way to do things, I think it'd look much more elegant especially (but not only) for nested arrays. 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 but I'd have to dive a bit deeper. Andi
Well, this discussion is really a stupid discussion. Obviously, there are some people, who likes this syntax ( in list() and array() form) but there are some people, who dislike it.
But I have to ask: what's the matter. A good programming language should not force the developer to program as the language wants. A good programming language should support the developer in writing code he likes, the way he likes.
Of course there could be problems with new developers. But the question is: is this relevant? - Should php as programming language only provide one syntax only because new developers could have problems (or not, I don't think, that would be a great problem, because in other languages, this syntax is already usable). - Should php only support one syntax so that every code is easier to maintain (if this is your only problem with foreign code, you are a really lucky guy!)
It don't think so: PHP is a good language, but writing code in PHP is sometimes awful. This could be improved by an alternative syntax. This could help new developers who are coming from another language. This could make coding funnier for some developers.
So: what's the matter? The idea of [] does not harm existent code. Everyone who does not like this syntax can avoid it in his code. But please don't tell others how they have to write their code! Let them write!
Mathias -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
