So I've been working on a small side project for the last few days, and I think that it's gotten to the point where I think that it's ready to be reviewed/critiqued.
The project is available on GitHub here: https://github.com/andrewlalis/streams
It introduces the concept of Streams, which is anything with either of the following function signatures:
int read(T[] buffer)
- this is an input stream.int write(T[] buffer)
- this is an output stream.
The README.md on the project's homepage describes the motivation in more detail, but in short, I'm not 100% satisfied with Phobos' ranges, and I think that streams could be introduced as a lower-level primitive that's also more familiar to programmers coming from a variety of other languages, while still trying to be as idiomatically D as possible.
Just for the sake of demonstration, here's an example of using streams to transfer the contents of a file to some arbitrary output stream. Of course pretty much anything done with streams can also be done with ranges, but I think that the simpler interface will make some things more ergonomic.
import streams;
void readFileTo(S)(string filename, S stream) if (isOutputStream!(S, ubyte)) {
import std.stdio;
auto fIn = FileInputStream(filename);
transferTo(fIn, stream);
}
So, I'd appreciate if anyone could take a look at my project, tell me if you think this is a good idea or not, if I should introduce a DIP for this change if added to Phobos (I know the DIP process is closed at the moment), or if you have any other feedback for this.