Revised RFC on range design for D2

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Fri Sep 12 08:29:34 PDT 2008


Bill Baxter wrote:
> On Fri, Sep 12, 2008 at 2:44 PM, 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).
>>
> 
> Looking better!
> 
> I disagree with this:
> """
> User code may pair iterators wrongly to create meaningless ranges. For
> example, given collections a and b of the same type, a.begin to
> b.begin makes no sense as a range, yet both the compiler and the
> runtime are hard-pressed in rejecting such mistakes. Such problems are
> often (though not always) avoided if range is the primitive.
> """
> 
> You can just as easily create nonsensical ranges using before() and
> after().  And I don't recall ever making the mistake of mixing up one
> container's begin() with another's end().
> 
> I disagree here too:
> """
> A bidirectional range models the natural way of iterating a doubly-linked list.
> """
> It maybe provides an efficient way to implement many algorithms on a
> doubly linked list.  But to say it implements the natural way of
> iterating one is a big stretch.

I hear you! I'll amend the doc later.

> r1=r.release  ==> r.transfer?  Release sounds like ref counting (e.g. in COM)
>                           Also seems like r.transfer(r1) could make
> implementation more efficient.
>                           Or perhaps make it a .swap like STL.  Maybe
> you have something against .swap?

Are you kidding? I wrote the best swap in the world. Check the source of 
std.algorithm.

You'll have to convince Bartosz about dropping the name "release". He 
held a gun to my head, and five of the six chambers were loaded. 
Couldn't take the risk. As far as efficiency goes, Walter has RVO down 
and all so I'm not worried.


Andrei


More information about the Digitalmars-d-announce mailing list