[squeak-dev] Recent change in byte array at:put:

Nicolas Cellier nicolas.cellier.aka.nice at gmail.com
Sat Jul 29 19:48:58 UTC 2017

2017-07-29 21:31 GMT+02:00 Tobias Pape <Das.Linux at gmx.de>:

> > On 29.07.2017, at 21:15, tim Rowledge <tim at rowledge.org> wrote:
> >
> > We recently changed ByteArray>at:put: to remove the backup conversion of
> the value to integer, for what seemed like decent reasons.
> >
> > It’s broken my WeatherStation code a little because there are places
> where I use
> > {my byte stream} nextPutAll: (aString squeakToUtf8)
> > or similar. #squeakToUtf8 returns a bytestring, and of course when the
> #nextPutAll: loop does its thing each character is pulled out as a
> Character (even though we know at this point it’s a byte value) - and we’ve
> just made it impossible to stick a character into a byte array.
> >
> > Clearly I could fix it reasonably trivially with a few #asByteArray type
> messages scattered around but it feels a bit tacky somehow. I see some
> faintly similar code with plausibly similar issues in WebSocket classes
> too, which would need some care. Not that I can see a lot of usage of that
> code…
> >
> > Performance isn’t a colossal issue for MQTT packets but it just rankles
> a bit to have a known byte valued string and then have to convert it to
> write it into a byte valued stream collection. KnowWhadIMean?
> >
> Underlying questions:
> - does an utf8 encoded string contain unicode-valued characters?
> -> is an utf8-encoded string a string after all?
> I'd suggest no out of purity but I'll expect yes from other out of
> practicality.
> Best regards
>         -Tobias
to me a String is a sequence of characters.
squeakToUtf8 is a hack that makes us consider a String as a sequence of
codePoints whose encoding is in the eye of the beholder (or implicitly in
the Context - the Smalltalk one).
I's not very object oriented and quite fragile.
We started to clean Multilingual but never finished the job...

It's difficult to finish it, because we value backward compatibility.
So maybe the ByteArray change was a bit radical with this respect.


> tim
> > --
> > tim Rowledge; tim at rowledge.org; http://www.rowledge.org/tim
> > Never write software that anthropomorphizes the machine. They hate that.
> >
> >
> >
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20170729/99496971/attachment.html>

More information about the Squeak-dev mailing list