Array Slice Ranges

Don Clugston dac at nospam.com.au
Thu Nov 9 06:55:17 PST 2006


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]
??



More information about the Digitalmars-d mailing list