[squeak-dev] anyone rely on this?

Bert Freudenberg bert at freudenbergs.de
Thu Jul 3 11:51:55 UTC 2014


On 03.07.2014, at 13:07, Frank Shearar <frank.shearar at gmail.com> wrote:

> On 3 July 2014 11:58, Bert Freudenberg <bert at freudenbergs.de> wrote:
>> 
>> And while we're on that topic, this is just wrong:
>> 
>> 'foo' asWideString asByteArray
>> => #[0 0 0 102 0 0 0 111 0 0 0 111]
> 
> Why is that wrong? Because #asByteArray doesn't make sense without
> specifying an encoding?

That, and it exposes endianness which is not a good idea either. Besides, this is what asByteArray is supposed to do:

asByteArray
	"Answer a ByteArray whose elements are the elements of the receiver."

... but "0" is not an element of that string in any sensible interpretation. I would expect

	'foo' asWideString asByteArray = 'foo' asByteArray

(and asByteArray should raise an exception for larger values)

Encoding the string would make sense, but is something else entirely, yes.

>> in particular since
>> 
>> #(1 2 3) asWordArray asByteArray
>> =>  #[1 2 3]

This is sensible, and does raise the exception.

- Bert -



-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4142 bytes
Desc: not available
Url : http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20140703/8a16bc38/smime.bin


More information about the Squeak-dev mailing list