Array Slice Ranges

Ary Manzana ary at esperanto.org.ar
Thu Nov 9 04:32:54 PST 2006


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?



More information about the Digitalmars-d mailing list