ch-ch-changes

Jarrett Billingsley jarrett.billingsley at gmail.com
Wed Jan 28 15:59:12 PST 2009


On Wed, Jan 28, 2009 at 6:00 PM, Joel C. Salomon <joelcsalomon at gmail.com> wrote:
> Jarrett Billingsley wrote:
>>
>> I was thinking about making D ranges be to D arrays as C++ iterators
>> are to C++ pointers: r[0] is head and r[$ - 1] is toe.  But that has
>> problems, since you can't make an infinite range, since you can't say
>> that r[0] is legal while r[$ - 1] is not.  (D also doesn't allow
>> overloading $, an irritating limitation, but one that could be fixed
>> in order to implement such a paradigm.)
>
>
> IIRC, Python uses negative indices to iterate from the end. Or is this
> entirely not what is under discussion?

Not really.  With the range interface the way it is now, you can make
a forward-only or infinite range by leaving out the "toe" and
"retreat" methods.  If "head" and "toe" were merged into a single
indexing operation, you wouldn't be able to do one-ended ranges like
that.



More information about the Digitalmars-d mailing list