On Fri, Sep 19, 2014 at 1:19 AM, Max Leske <maxleske@gmail.com> wrote:
This issue was more of a discussion between Camillo and Sven. They never reached a conclusion, so please take a look. I���ve compiled the transcript below.

The issue isn���t easy to solve and maybe we can just close it as ���not important���.

+1. ��But isn't the selector printString: broken? ��Shouldn't it be printAsString: ?
������



============
Camillo:
This method should be added to avoid many asString sends.

Example:
stream nextPutAll: #('ABC') asString could be written as stream printString: #('ABC').

This is a common extension of the following pattern:
stream nextPutAll: #('ABC') printString could be written as stream print: #('ABC').


============
Sven:
And what about #print: as implemented by Transcripts and SocketStreams ?

It is shorter.
Feels more familiar.


============
Camillo:
#print: is already implement and doesn't solve the stream nextPutAll: foo asString case. Since you cannot simply write stream print: foo, since you get quotes added for Strings.

Ok, I admit that with decent design you can avoid this, since it should almost never happen that you have a String or a non string object in the same variable, right?


============
Sven:
Yeah, that String issue is a bit annoying sometimes.
Indeed there is Stream>>#print: already.

But look:

ThreadSafeTranscript>>#print: anObject

�� �� self nextPutAll: anObject asString

how about that ?

There is also #<< whose implementation is even weirder, but it is handy.

The question remain: when do you want to mix Strings and other objects as arguments ?


============
Camillo:
- #<< is basically a lazy combination of #nextPut: and #nextPutAll:
- #print: should call #printOn: on the initial argument, which for strings defaults to storeOn: which I think is wrong, but I would hardly stand a chance changing that :P

So my global goal here is to avoid any kind of asString sends while pushing stuff on a stream. Sadly this happens more often than I thought :/


============
Sven:
Maybe this discussion should happen on the mailing list ?

Changing String>>#printOn: might be hard, but #<< is much more recent, no ? Could it not be changed to do what you want ? Like

Streamm>><< anObject
�� self nextPutAll: anObject asString

Another point is that #asString is not so efficient, since it creates throwaway Strings.



--
best,
Eliot