Re: Suggestion: echo function(var)[0];
| From: | mathieu.suen | Date: | Fri, 04 Jun 2010 08:19:35 +0000 |
| Subject: | Re: Suggestion: echo function(var)[0]; | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-48648@lists.php.net to get a copy of this message | ||
On 06/04/2010 10:00 AM, Richard Quadling wrote:
On 4 June 2010 08:18, mathieu.suen<mathieu.suen@easyflirt.com> wrote:--Mathieu SuenHi Why not something more generic. Someone could think of a ValueNode. Then it could be use for object, array, any primitive type ... I will take the ValueNode as a non terminal grammar node. So first we could do that: ValueNode->method(); ValueNode::sMethod(); ValueNode[]; foo(ValueNode); echo ValueNode; $e = ValueNode; ... And a ValueNode could be define as: ValueNode :Its called array-dereferencing and it was proposed countless times, including by myself. There is an RFC for this[1] and it was planned on the old PHP6 todo at the PDT[2]. [1] http://wiki.php.net/rfc/functionarraydereferencing [2] http://wiki.php.net/summits/pdmnotesmay09#php_6 (see point #13)NewStatement | FunctionCall | PrimitiveValue | '(' ValueNode ')' | ...;This would allow all this syntax: (new A())->foo(); foo(new A()); foo->bar()[1]; foo()[5]; and many others. On 06/04/2010 03:19 AM, Kalle Sommer Nielsen wrote:2010/6/4 Tig<tigger.on@gmail.com>:Hi TigWould be at all possible to implement this kind of shortcut?
Not an expert in this area, but does this mechanism limit you to usingsingle dimensional arrays? Of course not as soon as you add array access to a ValueNode ValueNode
..
| ArrayAccess
...;
This is very simple and it can refactor greatly the parser.
-- Mathieu Suen