Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:50625 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 45275 invoked from network); 27 Nov 2010 17:08:56 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 27 Nov 2010 17:08:56 -0000 Authentication-Results: pb1.pair.com smtp.mail=felipensp@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=felipensp@gmail.com; sender-id=pass; domainkeys=bad Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.214.42 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: felipensp@gmail.com X-Host-Fingerprint: 209.85.214.42 mail-bw0-f42.google.com Received: from [209.85.214.42] ([209.85.214.42:37974] helo=mail-bw0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C4/F1-32860-72B31FC4 for ; Sat, 27 Nov 2010 12:08:55 -0500 Received: by bwz13 with SMTP id 13so2765841bwz.29 for ; Sat, 27 Nov 2010 09:08:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:mime-version:received:in-reply-to :references:from:date:message-id:subject:to:cc:content-type; bh=XQBymZx/Kt9skcXnWS7xNgyEKdo7yinSO2rfnK9d9Ys=; b=agbCI52Ahtemv4WE67BfBjXV8qtg+EhRokLy6ZyzgSttJKtzxaWHrpn5+C0imkA94c ssERu2ZVFFDSZYNlPEX1tqy7yMzJv81M2mLf3xpEGBQiJXU+8bIQT1+rp1X6nFenX7/L sbPExYIneWFRbHKqEWclb2M+nChjiMJN7fsa8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; b=cf8Oiw8hpxar2ZK6M+KAqNW8/+IDNEpTSl2YfKBGTDxFdHUupD3zn5gWE/dqJVt2Fj aQXtYvQjAJnwssiuu8tr6AlEoifW5MZD13WCDAj/80sWzLAyGAdYb55WIN3bhstc1YX/ Kk7yzhQGIg0fJSBik3PaGFV1ilCCFJTx1stLg= Received: by 10.204.57.18 with SMTP id a18mr3052104bkh.164.1290877732456; Sat, 27 Nov 2010 09:08:52 -0800 (PST) MIME-Version: 1.0 Received: by 10.204.52.146 with HTTP; Sat, 27 Nov 2010 09:08:30 -0800 (PST) In-Reply-To: References: <1290802903.7033.772.camel@guybrush> Date: Sat, 27 Nov 2010 15:08:30 -0200 Message-ID: To: =?UTF-8?Q?Johannes_Schl=C3=BCter?= Cc: internals Content-Type: multipart/alternative; boundary=001636c5c272b10b0c04960be4ba Subject: Re: [PHP-DEV] [RFC] new foo()->bar() From: felipensp@gmail.com (Felipe Pena) --001636c5c272b10b0c04960be4ba Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Hi, 2010/11/26 Felipe Pena > 2010/11/26 Johannes Schl=C3=BCter > > On Fri, 2010-11-26 at 17:36 -0200, Felipe Pena wrote: >> > var_dump(new foo()->bar()->x); // string(3) "PHP" >> >> It has some readability issues. One might assume it is >> >> new (foo()->bar()->x) >> >> not >> >> (new foo())->bar()->x >> >> As there is a mandatory space between "new" and its operand and no space >> in front of the object operator and we allow non-constant operands to >> "new". >> >> So what is >> >> new $bar->foo(); >> >> ? If I read the patch correctly this is valid and evaluated as >> >> (new $bar)->foo(); >> >> johannes >> >> > > new foo()->bar() should be read as: (new foo())->bar(). > > And using variable: > > new $bar->y()->x should be read as: (new ($bar->y)())->x. > > > class foo { > public $x =3D 1; > } > > class bar { > public $y =3D 'foo'; > } > > $bar =3D new bar; > > var_dump(new $bar->y()->x); // 1 > > ?> > > I.e. just as it is nowdays. > Well, if this feature is going to be accept, we could to decide what syntax to use. I have created another patch which is the bracketed version of this presented here. y); // foo var_dump((new $x)->y); // foo var_dump((new $bar->y)->x); // 1 ?> Thus we do not have the readability issues, as pointed by Johannes. http://wiki.php.net/rfc/instance-method-call (updated!) Thanks for the comments. --=20 Regards, Felipe Pena --001636c5c272b10b0c04960be4ba--