Hi Jan, I like #<< too, but I think your assumption that it can print anything on a stream is generally wrong, dangerous and unreliable.
IMHO, you better stick to #print: in that case. Consider the follow, that all fail: String streamContents: [ :s | s << 'hello' << 42.5 << $! ]. String streamContents: [ :s | s << 'hello' << (1@2) << $! ]. In other words: #<< works in bizar ways (check the implementors of #putOn:). I would be inclined to change ZnEncodedStream>>#<< collection ^ self nextPutAll: collection to ZnEncodedStream>>#<< collection ^ self nextPutAll: collection asString but it would technically not be the same as the original #<< for in-memory streams. Opinions ? Sven > On 15 Feb 2019, at 09:52, Jan Blizničenko <jan.bliznice...@fit.cvut.cz> wrote: > > Hello everyone > > I am trying to use Pharo 7 for my project and I noticed that most of my > streams related code does not work anymore. Reason is that API for streams > received from writeStream of FileReference changed and I think it changed > for the worse in my case, because << does not properly handle any other > objects than strings anymore. > > In both Pharo 6 and 7 I can write > String streamContents: [ :s | s << 'hello' << 42 << $! ]. > and get 'hello42!'. > I can write in Pharo 6 but cannot in Pharo 7 > 'hello.txt' asFileReference writeStreamDo: [ :s | s << 'hello' << 42 << $! ] > In Pharo 6, I get same result in both examples (written to the file in > second case of course), but in Pharo 7, the second example results in > exception because << does not work with anything other than strings, so it > seems I have to manually convert everything to strings. > > This change to streams seems to me like a setback for 2 reasons: > 1) API amongst streams is no longer consistent in this case > 2) streams for files lost useful functionality and to make my project > compatible with Pharo 7, I have to make lots of effort to make my code > uglier and longer > > I would like to ask for the reason of this change and whether is there > anything that can be done with it. Or do I just misuse or misunderstand > anything? Thank you. > > Best regards, > Jan > > > > -- > Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html >