Why is there no std.stream anymore?

Steven Schveighoffer schveiguy at yahoo.com
Mon Dec 11 21:21:51 UTC 2017


On 12/11/17 3:51 PM, Jordi Gutiérrez Hermoso wrote:
> I'd like to read from a file, one byte at a time, without loading the 
> whole file in memory.
> 
> I was hoping I could do something like
> 
>     auto f = File("somefile");
>     foreach(c; f.byChar) {
>         process(c);
>     }
> 
> but there appears to be no such way to do it anymore. Instead, the 
> stdlib seems to provide several functions to do chunked reads from the 
> file where I have to manually manage the buffer. I see that D1 had a 
> stream, but it's no longer here and I understand ranges are supposed to 
> be used instead.
> 
> What's the explanation here? Why is there no more stream and what am I 
> supposed to use instead? Do I really need to be manually managing the 
> read buffer myself?

Use the undead repository:

http://code.dlang.org/packages/undead

https://github.com/dlang/undeaD

https://github.com/dlang/undeaD/blob/master/src/undead/stream.d

-Steve


More information about the Digitalmars-d-learn mailing list