RFC on range design for D2

Ary Borenszweig ary at esperanto.org.ar
Tue Sep 9 08:30:29 PDT 2008


Andrei Alexandrescu a écrit :
> Hello,
> 
> 
> 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.
> ...
> http://ssli.ee.washington.edu/~aalexand/d/tmp/std_range.html
> 
> 
> Andrei

It looks very nice, though I have a few questions:
- Is std.range's source code somewhere? Or it's just the documentation 
and then the implementation will follow? Because...
- How do you create a range? In the documentation it says that "Built-in 
slices T[] are a direct implementation of random-access ranges", so I 
guess a built-in slice is already a range. But if that is true...
- How is "void next(T)(ref T[] range)" implemented? If I pass a built-in 
slice to it, how does the template store the state of where in the range 
are we? Or maybe you'd need to do Range!(...) to create a range?
- What do I do to make a collection implement a range? Do I need to 
implement the templates in std.range using template conditions?

Sorry if my questions are silly, I don't know much about templated code.


More information about the Digitalmars-d-announce mailing list