Re: Array dereferencing using alternative array syntax

From: Date: Mon, 10 Oct 2011 09:03:40 +0000
Subject: Re: Array dereferencing using alternative array syntax
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-55771@lists.php.net to get a copy of this message
On Mon, Oct 10, 2011 at 1:30 AM, Peter Cowburn <petercowburn@gmail.com> wrote: > Hi Nikita, > > On 9 October 2011 18:14, Nikita Popov <nikita.ppv@googlemail.com> wrote: >> Hi list! >> >> PHP 5.4 added array dereferencing support (e.g. func()[1]), >> but the >> grammar seems to lack support for dereferencing using the alternative >> array access syntax (e.g. func(){1}). Was this done on >> purpose or >> was it just forgotten? > > I remember mentioning this on the list a while back, but didn't get > any further comment (it was an aside to a related thread).  I'd like > to see the curly brace alternative added, if only to be consistent > with the existing syntax to access array/string values that can be > used elsewhere. > >> >> Some links: >> >> >> http://lxr.php.net/xref/PHP_TRUNK/Zend/zend_language_parser.y#array_function_dereference >> ±~›¡n¥ïg�r�Ü >> �>http://lxr.php.net/xref/PHP_TRUNK/Zend/zend_language_parser.y#array_method_dereference >> >> http://lxr.php.net/xref/PHP_TRUNK/Zend/zend_language_parser.y#reference_variable >> (example of grammar with alternative syntax) >> hi, thanks for bringing this up. the alternate syntax has a rough past (if I remember correctly, [] was mentioned to be deprecated, then with 5.3 the preference was switched: [] is the preferred way now, and {} got almost deprecated), so if we plan to support the {} syntax on long term, I'm +1 for adding this to the language. I we plan to remove it eventually, then imo it is better to not introduce the support for the alternative syntax. -- Ferenc Kovács @Tyr43l - http://tyrael.hu

« previous php.internals (#55771) next »