Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:74804 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 76241 invoked from network); 9 Jun 2014 16:06:54 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 9 Jun 2014 16:06:54 -0000 Authentication-Results: pb1.pair.com smtp.mail=rowan.collins@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=rowan.collins@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.45 as permitted sender) X-PHP-List-Original-Sender: rowan.collins@gmail.com X-Host-Fingerprint: 74.125.82.45 mail-wg0-f45.google.com Received: from [74.125.82.45] ([74.125.82.45:39865] helo=mail-wg0-f45.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 8F/E4-45325-D9BD5935 for ; Mon, 09 Jun 2014 12:06:54 -0400 Received: by mail-wg0-f45.google.com with SMTP id l18so134656wgh.4 for ; Mon, 09 Jun 2014 09:06:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type; bh=1h3gXVdDqtgs3qmd8Vsb10J+YSgK2GPSQ+K2rIYlUBs=; b=MwtbqJClRQrcjDNAz9gkldwYWhJGqlNAh8C6WyKccUAIK6Ox+6x8c3i813EZNk1K4h 0SOD4KI7cfRjnEKedbqwB8Oi4mzhBuvS3ZT5MmV0iHIYsfVIFOhW3gY2qn0hXWorEZkL GHB2cpxNxgXsu/XoBgAciDzdSUkbBrd2Pukl0xXcxP2apdqyBnCGGePbxfflTmxIDvMs x/EJy9dcT7j7+j0ldh5zu7hEY0DQOWmxv9cBs/IJS9PKyPuPkx5GXhqLW9nyR9hejiHA eGP8ehwfdy7mzt+xb0Iiwv43X1mpC8JzPtJDJvW7LEZyNH/ioIz/2OGzdjRLBFVnEz0Y ZOng== X-Received: by 10.194.77.2 with SMTP id o2mr33277550wjw.68.1402330010262; Mon, 09 Jun 2014 09:06:50 -0700 (PDT) Received: from [192.168.0.139] ([62.189.198.114]) by mx.google.com with ESMTPSA id gr6sm15483252wib.10.2014.06.09.09.06.48 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 09 Jun 2014 09:06:49 -0700 (PDT) Message-ID: <5395DB90.40307@gmail.com> Date: Mon, 09 Jun 2014 17:06:40 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0 MIME-Version: 1.0 To: internals@lists.php.net References: <5395CC8D.5060702@anderiasch.de> In-Reply-To: <5395CC8D.5060702@anderiasch.de> Content-Type: multipart/alternative; boundary="------------060502090102000607060905" Subject: Re: [PHP-DEV] [RFC] [PHP 6] Uniform Variable Syntax From: rowan.collins@gmail.com (Rowan Collins) --------------060502090102000607060905 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Florian Anderiasch wrote (on 09/06/2014): >> Foo::$bar['baz']() Foo::{$bar['baz']}() (Foo::$bar)['baz']() >> >$foo->$bar['baz']() $foo->{$bar['baz']}() ($foo->$bar)['baz']() > Those last 2 lines (old meaning) are exactly as I would have read them > without thinking. So.. either I just got used to some kind of subliminal > rule over all these years or I'm missing something. I think it's somewhat subjective; it wouldn't have occurred to me that $foo->$bar['baz']() would evaluate $bar['baz'] rather than $foo->$bar. The advantage of the proposed behaviour is that it can be easily explained to *new* users of the language, as it's internally consistent, which appears not to be true of the old - an example in the RFC being |Foo::$bar[1][2][3] vs ||Foo::$bar[1][2][3]()| The ability for any length of expression to be evaluated consistently and according to an easily-explained logic makes this RFC a massive win for me unless anyone can come up with a case it changes that would already be in common use. If this had happened sooner, we wouldn't have needed separate RFCs for some_function()['array_key'] and (new Some_Class)->someMethod() > They're not variable variables, either. Technically, $foo->$bar is a "dynamic property access" (resolve the contents of $bar as a string, access that property), but it has a lot in common with what are commonly thought of as "variable variables"; if you have a class with property 'prop1', "normal" access would be via $foo->prop1, just as "normal" access to a variable would be $var1, not $$foo. There are slightly more cases where dynamic property access makes sense than plain variable variables (which can nearly always be replaced with an associative array), but exotic combinations like the ones affected here seem unlikely to be commonplace. Regards, -- Rowan Collins [IMSoP] --------------060502090102000607060905--