On Saturday, 5 September 2015 at 06:15:17 UTC, Jonathan M Davis
wrote:
On Friday, 4 September 2015 at 22:36:01 UTC, bitwise wrote:
On Friday, 4 September 2015 at 14:40:43 UTC, Jonathan M Davis
wrote:
[...]
Wow...this is surprising. At first glance, the streams seemed
to be fairly well done. What's the reason for them being
removed? and what is meant to be the replacement?
It's old (from D1) and does not follow the current best
practices or idioms. If we're going to have a stream solution,
it needs to be range-based. That being said, ranges in and of
themselves get pretty close to streams, and there simply hasn't
been a push to come up with a range-based stream solution where
the pieces that aren't already part of ranges are taken care
of. std.stream has been marked as scheduled for deprecation for
years, and no one has bothered to replace it. It comes up
periodically, but no one seems to care enough to do anything
about it. So, rather than leave it in that state, we decided
that it would be better off to just deprecate it and then get
rid of it rather than leave it in limbo with the documentation
saying that it's not up to our standards and that we're going
to get rid of it at some point. At some point, someone may come
up with a range-based stream solution and get it into Phobos,
but until then, we'll just use straight up ranges, which come
close enough for most cases. std.stdio and std.mmfile make it
quite possible to operate on files with ranges in a manner
similar to streams, and std.stdio allows you to operate on
stdin and stdout in a similar manner (since they're
std.stdio.Files).
That being said, std.stream is boost-licensed, and anyone is
free to copy it or fork it so long as the copyright notice is
left on it. So, anyone who wants to use std.stream in their own
code even after it's no longer in Phobos is free to do so. It's
just that the std.stream code is then going to have to be part
of their project rather than Phobos.
- Jonathan M Davis
Thanks for the explanation, but could you give an example of how
Stream would be rangified?
In the containers I'm writing, I'm returning a range from the
findAll() function instead of an array:
https://github.com/bitwise-github/d-containers/blob/master/collections/list.d#L901
I suppose any method returning an array/string could work like
this...Is this what you mean?
It doesn't seem like the entire Stream class should have to be
removed to make this change though.