RFC on range design for D2

Sergey Gromov snake.scaly at gmail.com
Mon Sep 8 16:06:48 PDT 2008


Andrei Alexandrescu <SeeWebsiteForEmail at erdani.org> wrote:
> Walter, Bartosz and myself have been hard at work trying to find the 
> right abstraction for iteration. That abstraction would replace the 
> infamous opApply and would allow for external iteration, thus paving the 
> way to implementing real generic algorithms.

opApply() wasn't my hero either. :)  Your article really looks like 
something I'd expect to find in D.  It only requires foreach support, 
and yeah, return by reference.

> I put together a short document for the range design. I definitely 
> missed about a million things and have been imprecise about another 
> million, so feedback would be highly appreciated. See:
> 
> http://ssli.ee.washington.edu/~aalexand/d/tmp/std_range.html

- next operation not mentioned in section 3, forward ranges.

- 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.

- what's a collection?  How do you get a range out of there?  Collection 
should be a range itself, like an array.  But it shouldn't be destroyed 
after passing it to foreach().  How to achieve this if foreach() 
essentially uses getNext()?

I'd really love to have this design in D though.


More information about the Digitalmars-d-announce mailing list