Revised RFC on range design for D2

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Fri Sep 12 10:39:51 PDT 2008


Sergey Gromov wrote:
> Andrei Alexandrescu <SeeWebsiteForEmail at erdani.org> wrote:
>> In wake of the many excellent comments and suggestions made here, I made 
>> one more pass through the draft proposal for ranges.
>>
>> http://ssli.ee.washington.edu/~aalexand/d/tmp/std_range.html
>>
>> There are some comments in red illustrating some uncertainties (not 
>> all), and the names of the primitives have been updated. Bicycle shed 
>> galore! But don't forget to comment on the reactor as well :o).
> 
> I've found superdan's post that convinced you.  I honestly cannot see 
> why.
> 
> Suppose I want to allow recycling in empty/next pair.  Then I cpecify 
> that:
> * next() returns stuff;
> * stuff is guaranteed to survive until the subsequent call to next();
> * stuff becomes undefined after next() is called again;
> * stuff is guaranteed to survive intermediate calls to empty().
> 
> The last point can make implementation more complex in some cases but 
> it's definitely possible to implement.
> 
> If we revert to empty/next, or whateve names you think better, then we 
> can also revert to using first/last for forward/bidirectional range 
> outermost elements and stop that body parts discussion.
> 
> I really hope this makes sense.

He did convince me. With your API you can't write efficient algorithms 
that work with input ranges and forward ranges crawling on actual 
containers.

Andrei


More information about the Digitalmars-d-announce mailing list