Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:56450 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 79091 invoked from network); 21 Nov 2011 07:59:39 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 21 Nov 2011 07:59:39 -0000 Authentication-Results: pb1.pair.com smtp.mail=irker@irker.net; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=irker@irker.net; sender-id=unknown Received-SPF: error (pb1.pair.com: domain irker.net from 209.85.215.170 cause and error) X-PHP-List-Original-Sender: irker@irker.net X-Host-Fingerprint: 209.85.215.170 mail-ey0-f170.google.com Received: from [209.85.215.170] ([209.85.215.170:56896] helo=mail-ey0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 97/E0-06281-9E40ACE4 for ; Mon, 21 Nov 2011 02:59:38 -0500 Received: by eyg7 with SMTP id 7so5080844eyg.29 for ; Sun, 20 Nov 2011 23:59:34 -0800 (PST) Received: by 10.213.17.146 with SMTP id s18mr1218249eba.16.1321862373442; Sun, 20 Nov 2011 23:59:33 -0800 (PST) MIME-Version: 1.0 Received: by 10.213.27.70 with HTTP; Sun, 20 Nov 2011 23:59:12 -0800 (PST) In-Reply-To: References: Date: Mon, 21 Nov 2011 11:59:12 +0400 Message-ID: To: Nikita Popov Cc: PHP internals Content-Type: multipart/alternative; boundary=0015174c364236036f04b23a11b6 Subject: Re: [PHP-DEV] New dereferencing syntaxes in 5.4 From: irker@irker.net (=?UTF-8?B?0JDQu9C10LrRgdCw0L3QtNGAINCc0L7RgdC60LDQu9GR0LI=?=) --0015174c364236036f04b23a11b6 Content-Type: text/plain; charset=UTF-8 Amateurish question to internals: Why can not we do more general cases? For example (expr)[3]; (expr)->foo->bar; (expr)()->baz[3]()->makeSomething()[4] = 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 = '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 > > --0015174c364236036f04b23a11b6--