Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:56669 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 68895 invoked from network); 30 Nov 2011 00:50:25 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 30 Nov 2011 00:50:25 -0000 Authentication-Results: pb1.pair.com header.from=devis@oracolo.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=devis@oracolo.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain oracolo.com designates 209.85.215.42 as permitted sender) X-PHP-List-Original-Sender: devis@oracolo.com X-Host-Fingerprint: 209.85.215.42 mail-lpp01m010-f42.google.com Received: from [209.85.215.42] ([209.85.215.42:60370] helo=mail-lpp01m010-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id DD/87-28705-ECD75DE4 for ; Tue, 29 Nov 2011 19:50:24 -0500 Received: by lami14 with SMTP id i14so11775lam.29 for ; Tue, 29 Nov 2011 16:50:19 -0800 (PST) Received: by 10.152.104.167 with SMTP id gf7mr32998661lab.46.1322614218409; Tue, 29 Nov 2011 16:50:18 -0800 (PST) MIME-Version: 1.0 Sender: devis@oracolo.com Received: by 10.152.21.40 with HTTP; Tue, 29 Nov 2011 16:49:36 -0800 (PST) In-Reply-To: References: Date: Wed, 30 Nov 2011 00:49:36 +0000 X-Google-Sender-Auth: 6npOJSJAvhgfQ2skrAfssxU3kFs Message-ID: To: =?UTF-8?B?0JDQu9C10LrRgdCw0L3QtNGAINCc0L7RgdC60LDQu9GR0LI=?= Cc: Nikita Popov , PHP internals Content-Type: multipart/alternative; boundary=f46d04071663a9c56304b2e91efd Subject: Re: [PHP-DEV] New dereferencing syntaxes in 5.4 From: devis@lucato.it --f46d04071663a9c56304b2e91efd Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Hi, is the new dereferencing syntax definitely part of 5.4 ? Will it be possible to replace this: $model =3D new DomainModel('foo', 'bar'); $result =3D $model->findByName('John'); with: $result =3D (new DomainModel('foo', 'bar'))->findByName('John'); ? Thank you Devis On 21 November 2011 07:59, =D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B0=D0=BD=D0=B4= =D1=80 =D0=9C=D0=BE=D1=81=D0=BA=D0=B0=D0=BB=D1=91=D0=B2 w= rote: > Amateurish question to internals: > Why can not we do more general cases? For example (expr)[3]; > (expr)->foo->bar; > (expr)()->baz[3]()->makeSomething()[4] =3D 16; etc. > > Now we have (new some)->something; and doSomething()[12], but why only this > cases? > > Big trouble in parser to do this? Can someone help me to find discussions > about it, if they exist. > > With regards, Alexander Moskaliov > Irker@irker.net > > > 2011/11/20 Nikita Popov > >> Hi internals! >> >> I want to discuss some details of the new dereferencing syntaxes which >> were introduced in 5.4. >> >> 1. I already mentioned lack of support for dereferencing using the >> alternative array syntax earlier >> (http://markmail.org/thread/j6rs3bzgzhxmco7n) but there was no >> conclusion on that topic. Now the (new A)[0] dereferencing syntax >> landed without alternative syntax too. Does this mean that the general >> consensus is to deprecate and remove the {} syntax altogether in the >> future? >> >> 2. PHP always supported doing $arr[0]() and 5.4 added the reverse >> func()[0]. The addition seems slightly inconsistent though, as the >> combination of both does not work: func()[0]() will result in a syntax >> error. Same applies to method array dereferencing. Is this >> intentional? >> >> 3. The new expression method, property and array dereferencing >> syntaxes were added in expr_without_variable. I am not sure whether >> this was intentional or not. That way (new A)->b will not be a >> variable (in the parser sense), whereas $a->b will. What is the impact >> of this? One thing that will not work is doing (new A)->b =3D 'c'. I >> know, this looks fairly stupid, but if you consider that A might >> overload the __set operation it might actually make sense. (It won't >> make much sense, but hey, (new A)[0] doesn't make much sense to me >> either). Other areas that might be affected are return by reference, >> pass by reference and iterate by reference (but I didn't test this). >> >> So, I know, those are all edge cases, so leaving them as is won't hurt >> much. Still I think it's better to discuss them ;) >> >> Nikita >> >> -- >> PHP Internals - PHP Runtime Development Mailing List >> To unsubscribe, visit: http://www.php.net/unsub.php >> >> > --f46d04071663a9c56304b2e91efd--