On 24 March 2013 14:06, Jonathan M Davis <[email protected]> wrote:
> On Sunday, March 24, 2013 13:55:26 Manu wrote: > > I'd like to clarify some conflicts I've encountered. > > > > TDPL talks about ranges, it mentions random access ranges requiring these > > functions: > > > > T at(int i) > > Range slice(int x, int y) > > This is not used by Phobos. I don't know why TDPL uses those. They are not > supported at all and AFAIK never have been. > My mistake; I stumbled upon an article written in 'CDJ#++', which I thought was an exert from TDPL (mixed my browser tabs up) >_< > Also, forward ranges require: > > > > Range save() > > > > But there is also this function: > > > > Range opSlice() > > > > With no args, handles the syntax 'range[]'. save() and opSlice() with no > > args would appear to be identical. > > Why have both? Which will be used in which cases? > > Range opSlice() > > is never used by ranges. It's only used by containers when you want to get > a > range for them. > So what's the difference between save() and opSlice() though? They appear to be identical regardless... is save() redundant? If you want to know exactly which functions are supported by ranges, and the > documentation isn't clear enough This is my point, _there is no documentation_. > just look at the definitions for the range > traits in std.range - isInputRange, isForwardRange, etc. They specify > exactly > what a type must do to qualify as each type of range. > I have been, but since I'm just digging, and have no authoritative reference, I am easily confused when I see conflicting or apparently redundant code. A D user shouldn't have to do this. I encourage a section under Language -> Language Reference on dlang.org, to anyone who is an authority on the topic.
