Hi Sven & Jan, On Fri, 15 Feb 2019 at 10:25, Sven Van Caekenberghe <sven@stfx.eu> wrote:
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 ?
I've often thought that this change would be nice to have. #putOn: doesn't really fit in with writing to text streams (text in the loose sense of "something that will be read"). I think an argument could be made that #printString or #displayString should be used, but they both have their own issues in practice. So... +1 to "collection asString". Cheers, Alistair