Bill Baxter wrote:
On Mon, Jan 19, 2009 at 9:16 AM, Andrei Alexandrescu
<[email protected]> wrote:
Unless it's a class you mean?
Yah, ranges are meant to have value semantics. If you have a class container
exposing ranges, define the range separately from the container itself:
MyIterable collection;
foreach (element; collection.all) {}
foreach (element; collection.all) {}
Add .opRange so that's not necessary? Or allow opApply to return a range?
Otherwise it looks like a step backwards.
Why is it a step backwards? A given container may define a number of
ranges. Arrays are deceivingly simple because they have one obvious way
of iteration, but even for them you'd have to write:
int[] a;
foreach (element; a.retro) { ... }
Andrei