Hi Bert, Hi Marcel,
I agree with Sven:
From: Sven Van Caekenberghe <sven@stfx.eu>
Date: April 26, 2018 at 6:36:42 AM PDT
To: Pharo Development List <pharo-dev@lists.pharo.org>
Subject: Re: [Pharo-dev] Fwd: ByteArray>>at:put:
Reply-To: Pharo Development List <pharo-dev@lists.pharo.org>
On 26 Apr 2018, at 15:21, Sean P. DeNigris <sean@clipperadams.com> wrote:
Relevant to Pharo?
From http://forum.world.st/ByteArray-at-put-tp4955848.html :
We don't (want to) mix binary and character collections or streams. Going from one to the other is called encoding and decoding, it has to be done while being conscious of which encoding you are using. Sending #asByteArray to a String or #asString to a ByteArray is dangerous, lazy and wrong (in most cases), especially in an international context.
So I would rather see an error or a convenience method such as nextPutAllBits: which does what the above does (implicitly convert) but is explicit. (ByteArray new: 5) writeStream nextPutAll: #[1 2 3 4 5] and (ByteString new: 5) nextPutAll: 'hello' should both raise an error (only the last does), as should (ByteArray new: 5) writeStream nextPut: $!. (ByteString new: 5) nextPut: 33 does. At least these operations should be consistent and symmetrical. Right now nextPut: is consistent with nextPutAll: but String<-Integer is not symmetric with ByteArray<-Character.