Are iterators and ranges going to co-exist?

Steven Schveighoffer schveiguy at
Mon Jul 19 14:06:44 PDT 2010

On Mon, 19 Jul 2010 16:37:22 -0400, Peter Alexander  
< at> wrote:

> I've been following the D programming language for quite some time now,  
> and only recently decided to dive in and start using it. My first  
> impressions are that it is a very nice language (despite the library  
> bugs), but one thing in particular that confused me was the lack of  
> iterators, and their near complete replacement by ranges.
> I did notice that there is an std.iterator library, which is said to be  
> "growing" in the documentation.
> What is the plan for this library? Will the std.algorithm start to use a  
> mixture of iterators and ranges (as it should, in my opinion)?

You may want to check out cursors from dcollections.  I apologize, the  
online docs are still for the D1 version, but you can learn about D2  
cursors here:

Note that cursors are still ranges, but enjoy many of the benefits that  
iterators are used for in STL, such as referring to single elements and  
using as endpoints for slices.

I'm unsure whether Andrei will admit them into phobos.  All correspondence  
I have with him both private and public indicates they will not be  
admitted.  But they are still ranges, so they effectively can be used in  
some alogrithms (though the usefulness in that capacity remains to be  
seen).  They should make 3-legged algorithms much easier to write, and  
code that gets ranges from a container much more natural.


More information about the Digitalmars-d mailing list