"Jonathan M Davis" <[email protected]> wrote in message
news:[email protected]...
> On Tuesday, July 10, 2012 21:07:51 Jacob Carlborg wrote:
>> Second, it would be much easier if it would be possible to better name
>> these ranges, something like interfaces but without polymorphism. This
>> as been mentioned several times before.
>
> They're templated types. They have to be templated types. And since
> they're
> templated types, better names do you no good whatsoever as far as
> declaring a
> variable goes. You'll _never_ be able to do something like
>
> NiceName range;
>
This isn't really true. You can still in some cases the type relative to
some other type. (warning: old code, may not compile any more)
Sure, you can use auto and typeof, but that doesn't make it clearer.
struct SubSequences(R)
{
R r;
R s;
Take!R c;
int n;
this(R r)
{
this.r = r;
s = r;
n = 0;
c = take(r, 1);
popFront();
}
void popFront()
{
c.popFront();
if (c.empty)
{
c = take(r, ++n);
s.popFront();
}
}
Take!R front() { return c; }
bool empty() { return s.empty; }
typeof(this) save() { return this; }
};
SubSequences!R subSequences(R)(R r) { return SubSequences!R(r); }