iopipe: Writing output to std.io File

Steven Schveighoffer schveiguy at gmail.com
Tue Jan 28 16:09:55 UTC 2020


On 1/28/20 1:25 AM, Jesse Phillips wrote:

> I really feel like this is all very well thought out and clean, I don't 
> appear to have a previous model to help visualize this output approach. 
> Right now something like tee is coming to mind. Thank you for explaining 
> with the answer.

Thanks! Tee is actually a pretty close approximation. For example, if 
you wanted to save to 2 files, you could do:

push!(p => p
    .encodeText
    .outputPipe(file1)
    .outputPipe(file2)
)

The whole advantage is that you don't need to use the output pipes as 
buffered output. For example, the convert function doesn't need them, it 
just pulls the whole thing (using the process function).

Everything is pulled with iopipe, even output, so it's just a matter of 
who is pulling and when. Pushing is a matter of telling the other end to 
pull.

-Steve


More information about the Digitalmars-d-learn mailing list