Range proposal

Bill Baxter wbaxter at gmail.com
Wed Sep 10 12:06:19 PDT 2008


On Thu, Sep 11, 2008 at 2:04 AM, Manfred_Nowak <svv1999 at hotmail.com> wrote:
> Bill Baxter wrote:
>
>> think of a range more as an iterator plus a sentinel
>
> The problem with both models is, that there are canonical operators one
> both models, which are somehow frantically hidden. This is shown
>
> 1) by the deliberately constructed compound of `[left,right]
> [Diff,Union]'
> 2) the missing definition of a "subrange"
>
> Both seem undefinable without having some notion of "concatenation"---
> and if one has concatenation, a request for the reverse operation
> "splitting" is unavoidable.
>
> In fact the semantics of `r.moveTo(s)' seems not to be fully defined in
> both approaches.
>
> In fact in your approach of thinking of `r.moveto(s)', the "iterator"
> of `s' turns into a "sentinel" for `r', thereby making sentinels and
> iterators to synonyms.

Well not necessarily synonyms, because how that iterator is turned
into a sentinel is up to the moveTo method.  But yeh, in most cases
they probably would be implemented under the hood using the same type
-- that's how STL works, after all, and it turns out reasonably well.
And probably how boost's ranges are implemented, just as a pair of
iterators... (though I admit I haven't taken a look at those at all).

--bb



More information about the Digitalmars-d mailing list