Hi!

>> My proposal is something similar to Pythons slice, in PHP this would look
>> like:
>>
>> $slided = $array[1:4]
>>
>> This will get the elements in positions 1,2,3,4. (1 through 4 inclusive),
>> ignoring the actual key of the array. The result for an array will be an
>> array with the keys preserved, in the same order.

I'm not sure how such operation would be useful, and it definitely would
not be intuitive, as $array[0] and $array[0:1] (assuming non-inclusive
semantic, or [0:0] with inclusive semantics) would return completely
different things. That would happen even if the array has only numeric
keys! This is the main problem with this syntax - unlike most languages
where it is used, PHP arrays are not vectors, they are ordered hashmaps.
Sometimes this is very convenient, sometimes - like for this syntax - it
is not. I think this is the major reason why such proposals failed in
the past.

-- 
Stas Malyshev
smalys...@gmail.com

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

Reply via email to