On Wed, 27 Mar 2019 at 17:18, Isaac Gouy via Pharo-users
<[hidden email]> wrote:
> From — "Pharo 7 file streams guideline"
> https://github.com/pavel-krivanek/pharoMaterials/blob/master/Filestreams.MD >
> I have some ideas like —
> in := ZnFastLineReader on: (ZnCharacterReadStream on: Stdio stdin). out := ZnBufferedWriteStream on:
> (ZnCharacterWriteStream on: Stdio stdout).
> What would be faster / better / more Pharo ways to do buffered reads and buffered writes to stdio ?
This is heading in the right direction. The buffered wrappers are
normally placed on the underlying binary stream, and then wrapped with
the encoder / decoder. Follow through FileReference>>writeStream and
FileReference>>readStream to see how it is done for files.
in := ZnFastLineReader on: (ZnCharacterReadStream on:
(ZnBufferedReadStream on: Stdio stdin)).
out := ZnCharacterWriteStream on: (ZnBufferedWriteStream on: Stdio stdout).
Note that if you're doing terminal IO you'll need to handle stdin differently.
If you're writing to a terminal on Linux / MacOS you'll need to use
LFs instead of Pharo's standard CRs, so it may be worthwhile adding
ZnNewLineWriterStream on: out.