Range Type
Xinok
xnknet at gmail.com
Mon Mar 24 09:26:35 PDT 2008
Janice Caron wrote:
> On 24/03/2008, Craig Black <cblack at ara.com> wrote:
>> I could be wrong, but I don't think this would be a big deal. The .. would
>> be interpreted differently when preceded by a type. The .. would work like
>> [].
>
> I don't think it would, because ".." is an infix operator, whereas
> "[]" is a postfix operator.
* is also an infix operator, and we seem to get along fine with that.
Regardless, I don't think it will work. How about if you have an array
of ranges?
[10..20, 20..30, 30..40]
How do you write that type?
This doesn't work:
int..int[]
Because, to me anyways, this translates to:
range!(int, int[])
Using .. should work for literals. All that is really needed is changing
the precedence of the operator.
Currently, writing this:
x = 0 .. 10
translates to:
(x = 0) .. 10
I think the precedence fits best somewhere between + - and =. This way,
we can write both:
x = 0 .. 10
arr[0 .. $ - 1]
More information about the Digitalmars-d
mailing list