Deprecation: module std.stream is deprecated

Spacen Jasset via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Nov 7 05:52:26 PST 2015


On Saturday, 7 November 2015 at 13:30:44 UTC, Jonathan M Davis 
wrote:
> On Saturday, November 07, 2015 12:10:05 Spacen Jasset via 
> Digitalmars-d-learn wrote:
>> Deprecation: module std.stream is deprecated - It will be 
>> removed from Phobos in October 2016.
>>
>> The std.stream module documentation doesn't give any clues as 
>> to what an alternative might be.
>>
>> I have this sort of code:
>>
>> this(InputStream input)
>>   {
>>
>>       int line_no = 1;
>>       foreach (char[] line; input) {
>>
>> Am I right in thinking to use std.stdio with an InputRange?
>
> At this point, you pretty much have three options:
>
> 1. Use std.stdio.File and read it in in pieces (e.g. with 
> byLine or
> byChunk).
>
> 2. Read the whole file in at once with std.file.read or 
> std.file.readText.
>
> 3. Use std.mmfile.MmFile to mmap the file so that the parts 
> that you access get read into memory, and the rest don't get 
> loaded from disk, but you get to operate on the whole file as 
> if you had read it all from disk.
>
> - Jonathan M Davis

Thanks Jonathan. I don't quite see what I want to do though.

In order to abstract the file aspect of things away, and deal 
with a stream of chars that could be from a file, or some some 
other source would I use a range?

what I am after is a replacement for InputStream, I don't really 
want to directly use File in most places.

So far I have this, and it seems to work, but it doesn't seem 
right:

this(InputRange)(InputRange input)
	{
		
		int line_no = 1;
		foreach (char[] line; input.byLine()) {
...

I have a used a template, because I cannot directly use the 
InputRange(char) interface as a type, and auto won't work either, 
so is there another parameter type I can use, such that I can 
have the concept of an abstract stream of bytes.


More information about the Digitalmars-d-learn mailing list