Re: [RFC] Bare Name Array

From: Date: Sun, 01 Jun 2014 20:03:32 +0000
Subject: Re: [RFC] Bare Name Array
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-74683@lists.php.net to get a copy of this message
On 1 Jun 2014, at 20:56, Adam Harvey <aharvey@php.net> wrote: > Andrea, did you consider implementing something more like Ruby's > symbols, rather than a variation on the existing array literal syntax? > I feel like that might solve any potential ambiguities in terms of > constant resolution (as mentioned in another subthread), wouldn't > require a separate [foo: bar] variant on the existing syntax, and may > be useful in other contexts too (such as array dereferencing). The problem with Ruby-style symbols is twofold. First, we don’t have a free character in PHP to use to denote a symbol, so it would have to be two characters. In that case, there’d be no advantage in using it over a string. Secondly, Ruby-style symbols are completely separate from strings, with symbol keys and string keys being different. Nothing in PHP deals with symbols, however, everything deals with strings. So for it to be useful we’d either have to start using it everywhere, which won’t happen, or have it just be another syntax for strings, which would be useless as it’s no shorter. > As for the array dereferencing syntax: it should probably be an RFC > and patch on its own. To be honest, my initial reaction is negative — > I think the proposed syntax blurs the lines between arrays and objects > (I know it's a different digraph, but it's going to look really > similar when scanning code), and I'm not yet sold on it being > particularly useful. I’m not entirely sold on :> either, but it’s the best idea I’ve had so far. I made a single RFC as I think the two features are complementary. As both use T_STRING, anything you can define with : you can dereference with :>, and the colon in :> is obviously inspired by the colon syntax. I may consider splitting the proposals into their own RFCs yet, though. I want to hold separate votes, anyway. -- Andrea Faulds http://ajf.me/

« previous php.internals (#74683) next »