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


-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to