[Pharo-users] Pharo 7 streams API

Peter Uhnák i.uhnak at gmail.com
Sat Jun 23 09:39:14 EDT 2018


I'm starting to familiarize myself with new streams, and one thing I've
noticed is the removal of #lineEndConvention (which I use all the time).

So a statement like this

aFile writeStreamDo: [ :stream |
stream lineEndConvention: #lf.
stream << '...'

has to be written like so

aFile writeStreamDo: [ :rawStream | |stream|
stream := (ZnNewLineWriterStream on: rawStream) forLf.
stream << '...'

which feels very messy because I am mixing writing with the configuration.
And I don't even take account for buffered/encoded decorators. Plus it
increases the incidental complexity -- I need another variable, and I can
accidentally write to the wrong stream, etc.

Would a method like #writeStream:do: (or #writeStreamTransform:do:) make
sense? E.g.

aFile writeStreamTransform: [ :stream | (ZnNewLineWriterStream on: stream)
] do: [ :stream |
stream << '...'

To separate the composition from the usage?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.pharo.org/pipermail/pharo-users_lists.pharo.org/attachments/20180623/42961209/attachment.html>

More information about the Pharo-users mailing list