Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:56693 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 93868 invoked from network); 30 Nov 2011 19:58:24 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 30 Nov 2011 19:58:24 -0000 Authentication-Results: pb1.pair.com smtp.mail=will.fitch@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=will.fitch@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.213.170 as permitted sender) X-PHP-List-Original-Sender: will.fitch@gmail.com X-Host-Fingerprint: 209.85.213.170 mail-yx0-f170.google.com Received: from [209.85.213.170] ([209.85.213.170:55263] helo=mail-yx0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 9F/2E-17272-0EA86DE4 for ; Wed, 30 Nov 2011 14:58:24 -0500 Received: by yenq5 with SMTP id q5so1051327yen.29 for ; Wed, 30 Nov 2011 11:58:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=subject:mime-version:content-type:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to:x-mailer; bh=rtHrxpiRInYrRbGEAVTdOd82xa6imgQC9XXGgbFmbHs=; b=uZdQhsynYkINHu1sNjqL/Mx5O7IvMsLLGDteaxqq8lfx0kpLsb3MSAOZe3rcHZ+xnv FT1XAzIr6kjd4z7WqWvdGFI5ulLdiSmteeN3W5E5jDqZH5V0xUmc69EDQbmnGViT+LQd AC9FYaUGSUTRGEcB7oEqfl4GJ59DA0WJdC6tk= Received: by 10.236.146.4 with SMTP id q4mr6215142yhj.105.1322683101780; Wed, 30 Nov 2011 11:58:21 -0800 (PST) Received: from [192.168.1.68] ([68.64.144.221]) by mx.google.com with ESMTPS id d6sm7490924anm.16.2011.11.30.11.58.19 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 30 Nov 2011 11:58:20 -0800 (PST) Mime-Version: 1.0 (Apple Message framework v1251.1) Content-Type: text/plain; charset=iso-8859-1 In-Reply-To: <4ED68940.3050502@ralphschindler.com> Date: Wed, 30 Nov 2011 14:58:17 -0500 Cc: Nikita Popov , internals Content-Transfer-Encoding: quoted-printable Message-ID: <90D867E2-E6FB-481D-B57C-911E5FE6A418@gmail.com> References: <4ED6713D.2050009@ralphschindler.com> <4ED67DCB.5090102@ralphschindler.com> <4ED68940.3050502@ralphschindler.com> To: Ralph Schindler X-Mailer: Apple Mail (2.1251.1) Subject: Re: [PHP-DEV] 5.4's New De-referencing plus assignment From: will.fitch@gmail.com (Will Fitch) If that's the case, then why not just add whatever $options is as a = parameter to your constructor. I'm not totally against this concept, = but this use is moot. On Nov 30, 2011, at 2:51 PM, Ralph Schindler wrote: > Ironically, quite the opposite is something I find useful: >=20 > ($foo =3D new MyComponent($bar))->configure($options); >=20 > In a single line, instantiate and configure (via an API call) an = object. The return of configure() is not important to me, but the = brevity of that workflow, and the result of "new" is. >=20 > -ralph >=20 >=20 > On 11/30/11 1:13 PM, Nikita Popov wrote: >> 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. >>=20 >> 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. >>=20 >> Nikita >>=20 >> On Wed, Nov 30, 2011 at 8:02 PM, Ralph Schindler >> wrote: >>> Nikita, >>>=20 >>> You're completely right about the expanded expressions, but I'm not = sure its >>> an edge-case per-se. >>>=20 >>> 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. >>>=20 >>> 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. >>>=20 >>> 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: >>>=20 >>> ($foo =3D new Foo)->bar() >>>=20 >>> // OR in bison >>> '(' variable '=3D' new_expr ')' >>>=20 >>> I did it, and I see other people doing it too. So I guess the = question is... >>> "how edge case is this edge case?" :) >=20 >=20 > --=20 > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php >=20