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

From: Date: Fri, 23 May 2008 15:18:10 +0000
Subject: Re: Short syntax for array literals [...]
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-37831@lists.php.net to get a copy of this message
I'm not using this syntax. But I don't oppose it. On 5/22/08, Stan Vassilev | FM <sv_forums@fmethod.com> wrote: > > Hi, > > I hear this often by other developers and I tend to agree with them, that arrays are used > often, and often nested, so that having a long syntax for array literals tend to produce less > legible code than in other scriping languages. > > $a = array(array(1,2), array(3,4), 5, 6); > > $b = array('a' => 1, 'b' =>2); > > We use arrays in our configurations, in passing complex parameters to functions, fetching > information from databases, basically everything. So it adds up. > > Some frameworks have somewhat funny attempts to remedy this by introducing > "shortcuts" like this: function a() { return func_get-args(); }. Of course this > doesn't work when you need to specify the key name, and the overhead isn't worth it. > > It looks as there may not be a specific reason not to allow the JS syntax as an alternative > syntax (while keeping the current one in parallel): > > $a = [[1, 2], [3, 4], 5, 6]; > > $b = ['a' => 1, 'b' =>2]; > > There shouldn't be confusion to the parser as the brackets aren't preceded by an > identifier. > > Was this discussed before on the list? > > Regards, > > Stan Vassilev -- Regards, Wang Yi

« previous php.internals (#37831) next »