RFC on range design for D2

Sean Kelly sean at invisibleduck.org
Mon Sep 8 18:06:22 PDT 2008


Andrei Alexandrescu wrote:
> Sean Kelly wrote:
>> Andrei Alexandrescu wrote:
>> ...
>>>
>>> After much thought and discussions among Walter, Bartosz and myself, 
>>> I defined a range design and reimplemented all of std.algorithm and 
>>> much of std.stdio in terms of ranges alone.
>>
>> Yup.  This is why I implemented all of Tango's algorithms specifically 
>> for arrays from the start--slices represent a reasonable approximation 
>> of ranges, and this seems far preferable to the iterator approach of 
>> C++.  Glad to hear that this is what you've decided as well.
> 
> That's great to hear, but I should warn you that moving from arrays to 
> "the lowest range that will do" is not quite easy. Think of std::rotate 
> for example.

I'll admit that I find some of the features <algorithm> provides to be 
pretty weird.  Has anyone ever actually wanted to sort something other 
than a random-access range in C++?  Or rotate one, for example?  These 
operations are allowed, but to me they fall outside the realm of useful 
functionality.  I suppose there may be some relation here to Stepanov's 
idea of a computational basis.  Should an algorithm operate on a range 
if it cannot do so efficiently?  And even if it does, will anyone 
actually use it?


Sean


More information about the Digitalmars-d-announce mailing list