Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:56689 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 86624 invoked from network); 30 Nov 2011 19:13:25 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 30 Nov 2011 19:13:25 -0000 Authentication-Results: pb1.pair.com smtp.mail=nikita.ppv@googlemail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=nikita.ppv@googlemail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain googlemail.com designates 209.85.215.42 as permitted sender) X-PHP-List-Original-Sender: nikita.ppv@googlemail.com X-Host-Fingerprint: 209.85.215.42 mail-lpp01m010-f42.google.com Received: from [209.85.215.42] ([209.85.215.42:60447] helo=mail-lpp01m010-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 64/DC-17272-45086DE4 for ; Wed, 30 Nov 2011 14:13:25 -0500 Received: by lami14 with SMTP id i14so383881lam.29 for ; Wed, 30 Nov 2011 11:13:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=H8231UIYTkphDVYgdFw14jdgrs+xYrnyqy6H2AA9mRU=; b=eobOXaSyoi+8Cg7JvfGBfiVqpgTLU1z4Dx3O9v0UHeFJm6ZBVm4z8vuTCOvtW+4cEb cOf29ZFH6uZ5E5OVhMxsSFvxfHTnzs1PiMO/TtvFfd6tssA4B2d/U54VJrE/uYfGaazQ 9UazgOQTUi5Z25ZF4bLG+R+W4lMqv0m8drKaY= MIME-Version: 1.0 Received: by 10.152.132.72 with SMTP id os8mr2485251lab.4.1322680401717; Wed, 30 Nov 2011 11:13:21 -0800 (PST) Received: by 10.152.9.131 with HTTP; Wed, 30 Nov 2011 11:13:21 -0800 (PST) In-Reply-To: <4ED67DCB.5090102@ralphschindler.com> References: <4ED6713D.2050009@ralphschindler.com> <4ED67DCB.5090102@ralphschindler.com> Date: Wed, 30 Nov 2011 20:13:21 +0100 Message-ID: To: Ralph Schindler Cc: internals Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] 5.4's New De-referencing plus assignment From: nikita.ppv@googlemail.com (Nikita Popov) To me the main problem here is that $bar =3D ($foo =3D new Foo)->bar() simply doesn't make much sense. It is equivalent to: $foo =3D new Foo; $bar =3D $foo->bar(); Which is much cleaner and easier to understand. The plain (new Foo)->bar() syntax *is* useful for cases like (new ReflectionClass($class))->implementsInterface('Foo'), where you need only one single bit of information from a class. Nikita On Wed, Nov 30, 2011 at 8:02 PM, Ralph Schindler wrote: > 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 ma= kes > 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: > > =A0($foo =3D new Foo)->bar() > > =A0// OR in bison > =A0'(' variable '=3D' 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?" :)