Array Slice Ranges
rm
roel.mathys at gmail.com
Thu Nov 9 10:22:31 PST 2006
Don Clugston wrote:
> rm wrote:
>> Ary Manzana wrote:
>>> Mike Parker escribió:
>>>> Alexander Panek wrote:
>>>>> I'd really like to have a distinction between exclusive and
>>>>> inclusive slicing. Maybe '..'(inclusive) and '..-'(exclusive) or
>>>>> similar, with '..' => '..-'. Not *that* beautiful, though .. maybe
>>>>> someone has a better suggestion.
>>>>>
>>>>
>>>> What about leaving ... as is and using ..+, or ...+, for inclusive?
>>>
>>> I think the best approach is to use standard mathematical notation:
>>>
>>> array[1 .. 5] == 1, 2, 3, 4, 5
>>> array(1 .. 5] == 2, 3, 4, 5
>>> array[1 .. 5) == 1, 2, 3, 4
>>> array(1 .. 5) == 2, 3, 4
>>>
>>> There's no confusion there when you know mathematical ranges. The
>>> only problem is it's a confusion to the compiler... maybe?
>>
>> well if compiler issues are no issues, than the most explicit would be:
>>
>> array[1 .. 5] == 1,2,3,4,5
>> array]1 .. 5] == 2,3,4,5
>> array[1 .. 5[ == 1,2,3,4
>> array]1 .. 5[ == 2,3,4
>>
>> roel
>
> so a[b[1..5].length]
>
> would become a[b]1..4[.length]
> ??
I don't know :-)
In the case you give .. I'd say it's still possible to find out the
correct sequencing, something like: ok, I found a range indicator (being
..), that should be surrounded by 2 two [] characters. Now, whether
that's efficient, ... , that's another question.
But I'm sure there are cases to be found that are always ambiguous.
roel
More information about the Digitalmars-d
mailing list