Re: Re: Short syntax for array literals [...]

From: Date: Wed, 28 May 2008 07:24:47 +0000
Subject: Re: Re: Short syntax for array literals [...]
References: 1 2 3 4 5 6 7 8  Groups: php.internals 
Request: Send a blank email to internals+get-37947@lists.php.net to get a copy of this message
On 5/28/08, Antony Dovgal <tony@daylessday.org> wrote: > On 28.05.2008 10:44, Rasmus Lerdorf wrote: > > > Today's web developer is typically writing half their app in some variety > of Ecmascript, either Javascript or Actionscript and this array syntax is > second nature to all those folks. > > > > I don't recall any languages to introduce new syntax because it's so handy > to those who come from PHP and I see no reasons for us to do it either. > I perfectly understand that we (well, you) did it many times in the > beginning, but I believe that time is now gone. > > The array syntax we have exists for many years and is used in gazillions > lines of code, > it's known to every developer who have ever seen a PHP script. > In the same time, the [] syntax will definitely confuse people (wth? this > surely looks like invalid syntax!) and will only help to those how don't > know PHP, but have a certain experience with *script languages, i.e. you're > going to do a favor for 1% and confuse the remaining 99%. percentage is way different. such "short array syntax" is a common ground for a lot of modern dynamic languages. and common ground is nice (it makes life easier not only to people who come to php from other languages, but also to people who would come to other languages, like javascript, after php) > And at last, but not least I don't see anything "more readable and > maintainable" in using square brackets to initialize arrays when the same > brackets are used to access them: > > $a = [$a[1][2], 3]; /* wth does this mean? */ initialize variable $a as array, with elements: 0) value-of-key "2" of array located at key "1" of old array $a 1) 3 difficult to "spell", but easy to understand -- Alexey Zakhlestin http://blog.milkfarmsoft.com/

« previous php.internals (#37947) next »