Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:27922 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 17411 invoked by uid 1010); 8 Feb 2007 22:46:09 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 17396 invoked from network); 8 Feb 2007 22:46:09 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 8 Feb 2007 22:46:09 -0000 X-Host-Fingerprint: 88.64.155.232 dslb-088-064-155-232.pools.arcor-ip.net Received: from [88.64.155.232] ([88.64.155.232:29010] helo=localhost.localdomain) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 45/24-00136-038ABC54 for ; Thu, 08 Feb 2007 17:46:08 -0500 Message-ID: <45.24.00136.038ABC54@pb1.pair.com> To: internals@lists.php.net Date: Thu, 08 Feb 2007 23:46:05 +0100 User-Agent: Thunderbird 1.5.0.7 (Windows/20060909) MIME-Version: 1.0 References: <011701c7482d$a39f6910$6500a8c0@zend.2k> In-Reply-To: <011701c7482d$a39f6910$6500a8c0@zend.2k> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Posted-By: 88.64.155.232 Subject: Re: Syntactic improvement to array From: phpinternals@thunder-2000.com (Mathias Bank) 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