Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:56687 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 83767 invoked from network); 30 Nov 2011 19:02:40 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 30 Nov 2011 19:02:40 -0000 Authentication-Results: pb1.pair.com header.from=ralph@ralphschindler.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=ralph@ralphschindler.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain ralphschindler.com from 209.85.213.42 cause and error) X-PHP-List-Original-Sender: ralph@ralphschindler.com X-Host-Fingerprint: 209.85.213.42 mail-yw0-f42.google.com Received: from [209.85.213.42] ([209.85.213.42:46284] helo=mail-yw0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 14/3C-17272-FCD76DE4 for ; Wed, 30 Nov 2011 14:02:40 -0500 Received: by ywt2 with SMTP id 2so1124902ywt.29 for ; Wed, 30 Nov 2011 11:02:37 -0800 (PST) Received: by 10.236.83.112 with SMTP id p76mr5836765yhe.118.1322679756886; Wed, 30 Nov 2011 11:02:36 -0800 (PST) Received: from ralph-mac.local (ip174-73-14-247.no.no.cox.net. [174.73.14.247]) by mx.google.com with ESMTPS id x17sm7854299anj.18.2011.11.30.11.02.35 (version=SSLv3 cipher=OTHER); Wed, 30 Nov 2011 11:02:36 -0800 (PST) Message-ID: <4ED67DCB.5090102@ralphschindler.com> Date: Wed, 30 Nov 2011 13:02:35 -0600 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:8.0) Gecko/20111105 Thunderbird/8.0 MIME-Version: 1.0 To: Nikita Popov CC: internals References: <4ED6713D.2050009@ralphschindler.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] 5.4's New De-referencing plus assignment From: ralph@ralphschindler.com (Ralph Schindler) Nikita, You're completely right about the expanded expressions, but I'm not sure its an edge-case per-se. The problem with the current syntax is that the resultant of the 'new' operation is lost UNLESS your chained method returns $this - which IMO makes it about as 1/2 as useful as it really could be. In the case of "new" though, the resultant is always an object, it seems like it should be permissible to change the parser to allow for variable assignment of the target object. I think for people just trying out this new behavior (by seeing it in the release notes as (new Foo)->bar()), the next logical thing is to try this syntax: ($foo = new Foo)->bar() // OR in bison '(' variable '=' new_expr ')' I did it, and I see other people doing it too. So I guess the question is... "how edge case is this edge case?" :) Unfortunately, this new feature was not in any preview release, it was only in a release candidate. -ralph On 11/30/11 12:51 PM, Nikita Popov wrote: > Hi Ralph! > > This (in it's current form) doesn't look like a good idea to me. You > are only handling yet another edge case. ($foo = $bar = new A)->bar() > would again not work. > > If we really want this kind of (expr)-> syntax, then it should really > accept *any* expr. But I am not quite sure whether this will work out > easily because in this case we can't be sue that expr is an object > (but maybe it'll be simple, I just don't know). > > Nikita > > On Wed, Nov 30, 2011 at 7:09 PM, Ralph Schindler > wrote: >> Hey all (Filipe), >> >> This was brought up in the thread "New dereferencing syntaxes in 5.4". >> >> I too think this would be beneficial: >> >> $value = ($obj = new Foo)->produceAValue(); >> >> but the current parser (branch 5.4) doesn't have a rule for this. I've >> attached a quick/working patch, but I don't fully understand the >> ramifications of such a patch. >> >> Can someone explain the drawbacks of increasing the "%expect n" for me? >> >> Would this many s/r require/benefit from a new expression grouping? >> >> More to the point, can we have this small change for 5.4? >> >> Thanks in advance. >> -ralph >> >> -- >> PHP Internals - PHP Runtime Development Mailing List >> To unsubscribe, visit: http://www.php.net/unsub.php