I'll come back with a more complete answer latter, but first.
spir Wrote:
> * I wrote Range as class, but I rather meant an interface. D does not let me
> do that, apparently because there is no data slot in a D interface. Is then
> an interface a kind of data-less superclass? Or is there something I
> misunderstand?
Interfaces describe what can something of that type can do, not what it has.
Data fields are not allowed only function signatures and functions that perform
local modifications.
> auto range = ...;
> while (range.continues) {
> doSomethingWith(range.element);
> range.step();
> }
Note that you are not actually using a Range as it is defined by D. In fact it
is exactly the same, but named differently, here is what D's range interface
looks like.
> auto range = ...;
> while (!range.empty) {
> doSomethingWith(range.front);
> range.popFront();
> }