On Mar 20, 2015, at 16:27, Alex Bowers <bowersb...@gmail.com> wrote:

> On 20 March 2015 at 20:10, Sean Coates <s...@seancoates.com> wrote:
> 
>> That’s no different than `@` being invalid because it’s already in use.
> 
> 
> The syntax would be [*from:to], which would currently throw a parse error
> (since asterisk is required to be placed between two numbers), so this
> would be different.
> 
> Alternatively, an underscore could be used
> 
> This would then look like [_from:to]
> 
> Also, another option would be to not use the square bracket syntax at all,
> and move towards angled brackets for positional indexing.
> 
> This would then be $array<1:2> to get items in positions 1 and 2.

$array<1:2> could be confusing to parse (if not confusing to read) because of 
ambiguity with the existing < and > operators. For example:

        $foo ? $bar<1:2> 3

is currently valid syntax, and means

        $foo ? ($bar < 1) : (2 > 3)

So there is probably some complex nesting of ?: and <:> that is entirely 
ambiguous.

Not necessarily saying it can’t be done, but I think we should probably avoid 
syntax with a significant chance of causing mental parse errors.

-John


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

Reply via email to