When you say restrict to one each. Do you mean one for strings and one for arrays?
If so I'd have to disagree with this, since having the same operation available to both is less likely to give mistakes. Can you give an example of an actual benefit for this? Since this would cause a backwards incompatible change. I can't imagine many places if any use the curly brackets for arrays or strings, but since it exists there may be people using it. Changing the behaviour of this to only work for one of the two options seems unnecessary in the name of making code slightly more apparent on initial reading. But variable names and so on should be used to help distinguish from array or strings anyway. On 20 Mar 2015 17:02, "Vik Hudec" <vikhu...@yahoo.com> wrote: > Hi Alex, > > On Fri, 2015-03-20, at 14:52, Alex Bowers wrote: > > > But I don't think we should only match {} for strings and [] for arrays, > > that seems broken to me. > > > Maybe you misunderstand me, I am against using two syntaxes for different > > things. > > Based on your reply; yes, I'm definitely misunderstanding! In summary, we > already have two different operations: > > (1) Accessing an array's element using subscript notation, eg: > $foo = array('bar'); var_dump($foo[0]); // string(3) "bar" > > (2) Accessing a string's character using subscript notation, eg: > $foo = 'bar'; var_dump($foo[0]); // string(1) "b" > > And we already have two different syntaxes: $var[$offset] and > $var{$offset}. > > So we have two syntaxes that each perform two operations. Are we in > agreement that this isn't a good thing? > > Sorry that this is all a little off-topic, but I'm interested in people's > opinions because I'm considering a future RFC. My proposition would be to > restrict the two subscript syntaxes to one operation each. And if your > slice > sugar RFC aims to augment the functionality of either one or both of these > syntaxes, then that's relevant to me. > > Vik > >