Deprecation: module std.stream is deprecated

Spacen Jasset via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Nov 10 08:31:05 PST 2015


On Tuesday, 10 November 2015 at 11:57:03 UTC, Jonathan M Davis 
wrote:
...
> building blocks rather than kitchen sinks. And most range-based
...

I still can't really see why byChunk and byLine are part of the 
File API? Especially byLine, I'll get byChunk go for now.

I think what I am trying to say is that there doesn't need to be 
a byLine, if lineSplitter could work with some range that comes 
out of the File.

The problem with your example using joiner is that:

(a) it is external to the calling function, and therefore messy, 
since it will have to be used everywhere.

// not ideal
printFile(f.byChunk(1000).joiner());


(b) still can't use the range to split by lines afterwards, 
lineSplitter etc don't work.

void printFile(Range)(Range i)
{
     foreach (l; lineSplitter(i)) {
         writefln("%d\n", l);
     }
}

void main()
{
     File f = File("/etc/passwd");
     printFile(f.byChunk(1000).joiner()); // Not work, 
linesplitter needs slicing and length?
}





More information about the Digitalmars-d-learn mailing list