Change representation of dynamic arrays?

Janice Caron caron800 at googlemail.com
Sat Oct 20 02:25:58 PDT 2007


On 10/20/07, Janice Caron <caron800 at googlemail.com> wrote:
> On 10/20/07, Chris Miller <chris at dprogramming.com> wrote:
> > Or perhaps you
> > want a slice to be an iterator itself, so you could just do slice++ and it
> > slices out the first element.
>
> It would be very counterintuitive if ("world"++ == "orld"), so I don't
> think I'd like that.

To add to that, iterators in general are not range checked, because
they are generalised pointers, not generalised indeces.

You could argue that perhaps they /should/ be range checked (at least,
in debug builds in D), but to achieve that, you'd need a struct
containing not two, but /three/ pointers - one to the start of the
slice, one to the end of the slice, and one to the thing pointed at.
Otherwise you'd never be able to do --p.



More information about the Digitalmars-d mailing list