RFC on range design for D2

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Wed Sep 10 07:37:38 PDT 2008


Sergey Gromov wrote:
> Andrei Alexandrescu <SeeWebsiteForEmail at erdani.org> wrote:
>> Sergey Gromov wrote:
>>> - the union operations look... weird.  Unobvious.  I'm too sleepy now to 
>>> propose anything better but I'll definitely give it a try.  The rest of 
>>> the interface seems very natural.
>> I agree I hadn't known what primitives would be needed when I sat down. 
>> Clearly there was a need for some since individual iterators are not 
>> available anymore. New ideas would be great; I suggest you validate them 
>> by implementing some nontrivial algorithms in std.algorithm with your, 
>> um, computational basis of choice :o).
> 
> r.before(s)
> r.after(s)
> r.begin
> r.end
> 
> Here r.before(s) is everything from the r's first element (inclusive) to 
> the first s's element (exclusive); r.after(s) is from last s's element 
> (exclusive) to the last element of r (inclusive); r.begin is an empty 
> range at the beginning of a parent range; and r.end is an empty range at 
> the end of a parent range.  Therefore, according to your diagram: 
> 
> r.toBegin(s) => r.before(s)
> s.toEnd(r) => s.before(r.end)
> s.fromEnd(r) => s.after(r)

Cool! I was thinking of something along the same lines through the 
night, and actually with the same names before and after, but the begin 
and end did not occur to me. As soon as I'll have another chunk of time, 
I'll make another pass through algorithm2 to see how these work. But you 
may as well want to take std.algorithm and make it work with your 
primitives.


Andrei


More information about the Digitalmars-d-announce mailing list