Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:48648 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 27116 invoked from network); 4 Jun 2010 08:19:41 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 4 Jun 2010 08:19:41 -0000 Authentication-Results: pb1.pair.com header.from=mathieu.suen@easyflirt.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=mathieu.suen@easyflirt.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain easyflirt.com designates 91.199.255.56 as permitted sender) X-PHP-List-Original-Sender: mathieu.suen@easyflirt.com X-Host-Fingerprint: 91.199.255.56 python-06.easyrencontre.com Linux 2.6 Received: from [91.199.255.56] ([91.199.255.56:38213] helo=mail.easyflirt.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 19/A3-07323-B17B80C4 for ; Fri, 04 Jun 2010 04:19:40 -0400 Received: from [192.168.0.51] (office.easyrencontre.com [78.155.152.6]) by mail.easyflirt.com (Postfix) with ESMTPSA id 630396374E9; Fri, 4 Jun 2010 10:19:36 +0200 (CEST) Message-ID: <4C08B717.9020304@easyflirt.com> Date: Fri, 04 Jun 2010 10:19:35 +0200 User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.9) Gecko/20100423 Thunderbird/3.0.4 MIME-Version: 1.0 To: RQuadling@googlemail.com CC: Richard Quadling , internals@lists.php.net References: <4C08A8B6.7080905@easyflirt.com> In-Reply-To: Content-Type: multipart/alternative; boundary="------------000903080003060108070207" Subject: Re: [PHP-DEV] Suggestion: echo function(var)[0]; From: mathieu.suen@easyflirt.com ("mathieu.suen") --------------000903080003060108070207 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 06/04/2010 10:00 AM, Richard Quadling wrote: > On 4 June 2010 08:18, mathieu.suen wrote: > >> Hi >> >> 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 : >> >> 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: >> >>> Hi Tig >>> >>> 2010/6/4 Tig: >>> >>> >>>> Would be at all possible to implement this kind of shortcut? >>>> >>>> >>> 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) >>> >>> >>> >> >> --Mathieu Suen >> >> >> >> >> > Not an expert in this area, but does this mechanism limit you to using > single 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 --------------000903080003060108070207--