OK, I that is what I expected. 
I will study this again and make a PR with better comments and tests.

> On 18 Feb 2019, at 16:32, ducasse <steph...@netcourrier.com> wrote:
> 
>> 
>> 
>> I have been thinking a bit more about this, and I have a lot of problems with
>> 
>> Integer>>#putOn: aStream
>>      aStream isBinary
>>              ifTrue: [ self asByteArray do: [ :each | aStream nextPut: each 
>> ] ]
>>              ifFalse: [ self asString putOn: aStream ]
>> 
>> I think we should simply remove this method. It is ugly and wrong.
> 
> I agree
> 
>> #<< should simply be a shortcut for either #nextPut: and #nextPutAll: and 
>> nothing more.
>> 
>> The following two are OK for me:
>> 
>> String streamContents: [ :out | out << 'Hello' << $! ].
>> ByteArray streamContents: [ :out | out << #[ 1 2 3 ] << 4 ].
>> 
>> But the following most definitively not:
>> 
>> (ByteArray streamContents: [ :out | out << 16rFF << 16rFF11 << 16rFFFF22 << 
>> 16rFFFFFF33 ]) hex.
>> 
>> When you write out an integer, you have to decide its size, that can never 
>> depend on the magnitude (because there is no way to read this back unless 
>> there is additional bracketing).
>> 
>> Also, printing to a stream should be (very) efficient. Making copies of 
>> objects just for conversion purposes should be avoided.
> 
> yes.
> 
>> 
>> I think that if we remove Integer>>#putOn: I could live with 
>> 
>> ZnEncodedStream>>#<< anObject
>>      anObject putOn: self
> 
> Yes :)
> and remove the ugly one? Yes 
> 
>> 
>> The other solution is to define #<< as strictly the same as #nextPutAll: and 
>> remove all #putOn: implementors.
>> 
>> Sven


Reply via email to