Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:48660 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 73946 invoked from network); 5 Jun 2010 10:47:36 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 5 Jun 2010 10:47:36 -0000 Authentication-Results: pb1.pair.com smtp.mail=newrevolutions@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=newrevolutions@gmail.com; sender-id=pass; domainkeys=bad Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.212.42 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: newrevolutions@gmail.com X-Host-Fingerprint: 209.85.212.42 mail-vw0-f42.google.com Received: from [209.85.212.42] ([209.85.212.42:54811] helo=mail-vw0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id AC/F0-02771-74B2A0C4 for ; Sat, 05 Jun 2010 06:47:36 -0400 Received: by vws15 with SMTP id 15so2549286vws.29 for ; Sat, 05 Jun 2010 03:47:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:cc:content-type; bh=FQgbl2CSdgkNcFYFJO5xZUwZi7lo1CnAu5QL+KBw4WE=; b=M3FQBbW5xWFjrMV7WeapB3kyzIbM9ASYqbJByZbr8XD9fyPbWRD0udEyqOU1cRkJoz Rxj97sBSnawgiG46aE7B5RfyzWR1B3GZzd4LWIGB+TEB2oK2I7hs+1nI+SSUy0f6T8M7 GPG7XeyLNRTm9gZZAKi9vKfszGLmgcyPBMfZk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=UDXWWzmooH00FpJqD6zjnXydInp4z7uJ1gFJ/VsF8pIKjk2kFDF9BgrfLd8DZ4gFqc VjMcWwlHQLV1nbDrandK6hb7u2Hu/23Bbg2pMzbDsZxXRxv549iuStafRaI9MdBeDdeq AnHv3HoJZY/4jydrwRTAFHeCnxAHvwf+dBK7I= MIME-Version: 1.0 Received: by 10.220.107.105 with SMTP id a41mr8578792vcp.199.1275734853030; Sat, 05 Jun 2010 03:47:33 -0700 (PDT) Received: by 10.220.94.208 with HTTP; Sat, 5 Jun 2010 03:47:32 -0700 (PDT) In-Reply-To: <4C08B717.9020304@easyflirt.com> References: <4C08A8B6.7080905@easyflirt.com> <4C08B717.9020304@easyflirt.com> Date: Sat, 5 Jun 2010 18:47:32 +0800 Message-ID: To: "mathieu.suen" Cc: RQuadling@googlemail.com, Richard Quadling , internals@lists.php.net Content-Type: multipart/alternative; boundary=00c09f8c2623be17d30488462a85 Subject: Re: [PHP-DEV] Suggestion: echo function(var)[0]; From: newrevolutions@gmail.com (Harrison Yuan) --00c09f8c2623be17d30488462a85 Content-Type: text/plain; charset=ISO-8859-1 I don't understand what is holding PHP back from having this syntax. Tig said: The need to assign the trivial variable $tmp first is completely arbitrary. Is it not a design goal somewhere that languages should allow the greatest degree of literal expression possible, consistent with existing syntax & semantics rules? I am new here but would be interested in helping with a patch (+ hopefully another RFC) for this. What exactly are the specific arguments against array dereferencing? - Harrison On Fri, Jun 4, 2010 at 4:19 PM, mathieu.suen wrote: > 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 > > > > --00c09f8c2623be17d30488462a85--