On Fri, 11 Mar 2011 21:29:42 -0500, dsimcha <dsim...@yahoo.com> wrote:
The discussion we've had here lately about reading gzipped files has
proved
rather enlightening. I therefore propose the following high-level
design for
streams, with the details to be filled in later:
1. Streams should be built on top of input and output ranges. A stream
is
just an input or output range that's geared towards performing I/O
rather than
computation. The border between what belongs in std.algorithm vs.
std.stream
may be a bit hazy.
No. You will find when you go to implement this that it's awkward and
low-performing.
2. Streams should be template based/structs, rather than virtual
function
based/classes. This will allow reference counting for expensive
resources,
and allow decorators to be used with zero overhead. If you need runtime
polymorphism or a well-defined ABI, you can wrap your stream using
std.range.inputRangeObject and std.range.outputRangeObject.
This will have a viral effect on anything that uses an input/output
stream, making everything a template. Streams happen to be one of the
main types that scream "please, use polymorphism for me!"
For example, how would you easily replace stdin to be a network stream?
/me must get going on stream library before it's too late...
-Steve