[phobos] Ranges using runtime interfaces
Shin Fujishiro
rsinfu at gmail.com
Fri Aug 20 21:06:30 PDT 2010
David Simcha <dsimcha at gmail.com> wrote:
> Hmm. It's worth considering, but I see at least two problems.
>
> 1. Do we have a practical use case for it? I don't generally believe
> in adding complexity without clear use cases for said complexity.
I'm not sure. I/O-related ranges tend to have chunk-writing overloads:
void put(E value);
void put(E[] chunk);
And the Appender has a similar overload for bulk appending. But such
ranges can work with only one of those overloads.
> 2. The base interface is OutputRange!(E). If I change the base
> interface to OutputRange!(E...), then OutputRange!(uint, double) won't
> be a subtype of OutputRange!(uint). This is self-evidently ridiculous.
> I could maybe make OutputRangeObject!(E...) inherit from
> OutputRange!(E[0]), OutputRange!(E[1]), ..., OutputRange!(E[$ - 1]), but
> other than nasty string mixins D doesn't provide a way to inherit from a
> tuple of interfaces.
Oh, really? That's bad. I thought tuples could be used in the class
inheritance list. IIRC something like the following also does not work
due to a deep inheritance bug:
interface OutputRange(E...) : OutputRange!(E[1 .. $]) {
void put(E[0] e);
}
Then, maybe we should put off supporting this anyway...
> On 8/20/2010 9:26 PM, Shin Fujishiro wrote:
> > David Simcha<dsimcha at gmail.com> wrote:
> >
> >> In addition to the changes I made last night, I've also made the
> >> following changes:
> >>
> >> 1. Change name to inputRangeObject/InputRangeObject.
> >> 2. Add support for output ranges as outputRangeObject/OutputRangeObject.
> >> 3. Remove the now ridiculous looking Hungarian notation on the interfaces.
> >>
> >> http://pastebin.com/U83YNJfJ is where it's at.
> >>
> >> Any more comments from anyone, or does this look ready to be checked in?
> >>
> > Could you make OutputRangeObject able to accept multiple element types?
> >
> > template outputRangeObject(E...) {
> > auto outputRangeObject(R)(R range) { ... }
> > }
More information about the phobos
mailing list