Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:56441 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 87941 invoked from network); 20 Nov 2011 15:42:55 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 20 Nov 2011 15:42:55 -0000 Authentication-Results: pb1.pair.com header.from=nikita.ppv@googlemail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=nikita.ppv@googlemail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain googlemail.com designates 209.85.161.42 as permitted sender) X-PHP-List-Original-Sender: nikita.ppv@googlemail.com X-Host-Fingerprint: 209.85.161.42 mail-fx0-f42.google.com Received: from [209.85.161.42] ([209.85.161.42:45389] helo=mail-fx0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id CA/04-46773-EFF19CE4 for ; Sun, 20 Nov 2011 10:42:55 -0500 Received: by faas12 with SMTP id s12so104169faa.29 for ; Sun, 20 Nov 2011 07:42:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; bh=Q+SqOH1Q1F5BvTvRmsgIEDhZI57ZV1hFlbdRqwQPtaw=; b=WajDAyfn5Z4jeDn0nF1B2wPauy6wD0TcAZJPnzJvmDf9JPC9GJ3qjWaB0e68/Hyzv/ h3MIrrcaDIjBa1wZV0968G0/MCnxOPGkUyCLmfURSfykRDocvwPXLR72uZgifX6FSJOP 6EBdULHsB9G5cn0Bd4Tp4xqLBWS+eR9Fkud0Q= MIME-Version: 1.0 Received: by 10.152.105.132 with SMTP id gm4mr6713946lab.39.1321803772049; Sun, 20 Nov 2011 07:42:52 -0800 (PST) Received: by 10.152.26.111 with HTTP; Sun, 20 Nov 2011 07:42:51 -0800 (PST) Date: Sun, 20 Nov 2011 16:42:51 +0100 Message-ID: To: PHP internals Content-Type: text/plain; charset=ISO-8859-1 Subject: [PHP-DEV] New dereferencing syntaxes in 5.4 From: nikita.ppv@googlemail.com (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