Range documentation
Jonathan M Davis
jmdavisProg at gmx.com
Sat Mar 23 21:42:21 PDT 2013
On Sunday, March 24, 2013 14:31:44 Manu wrote:
> So what's the difference between save() and opSlice() though? They appear
> to be identical regardless... is save() redundant?
Like I said, opSlice with no arguments is the function used on containers to
get a range for that container. It's never defined on ranges, and even if
someone were to define it on one of their ranges, it wouldn't be used except in
code they wrote which used. save is the function which is used to copy a
range, and it's required for a range to be considered a forward range.
Theoretically, opSlice with no arguments could have been reused for that, but
it wasn't.
> 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.
Yes. We need a good article on ranges. I keep meaning to write one but haven't
gotten around to it (and if anyone else has been planning on it, they haven't
written it yet either). In the meantime, I suggest that you read the chapter
on ranges in Ali Çehreli's book:
http://ddili.org/ders/d.en/ranges.html
There's also Walter's article on component programming which does a good job
of explaining some of the motivation behind ranges and some good uses for them
but doesn't really go into detail on their exact API beyond what's necessary
in order to get his point across:
http://www.drdobbs.com/architecture-and-design/component-programming-in-d/240008321
- Jonathan M Davis
More information about the Digitalmars-d
mailing list