On Sunday, 23 March 2014 at 00:50:34 UTC, Walter Bright wrote:
It's become clear to me that we've underspecified what an
InputRange is. The normal way to use it is:
while (!r.empty) {
auto e = r.front;
... do something with e ...
r.popFront();
}
no argument there. But there are two issues:
1. If you know the range is not empty, is it allowed to call
r.front without calling r.empty first?
If this is true, extra logic will need to be added to r.front
in many cases.
2. Can r.front be called n times in a row? I.e. is calling
front() destructive?
If true, this means that r.front will have to cache a copy in
many cases.
It would be nice to have ranges full stop described. And how to
use/make them in D. I have yet to learn them because of no
official documentation on them.
On this topic we also need to work on common patterns and
creating documentation on e.g. the site or wiki for it. Saw that
we do have a bit in the wiki under tutorials. Maybe if I get some
time I'll work on that.