[squeak-dev] Re: The Trunk: TrueType-nice.13.mcz

Colin Putney cputney at wiresong.ca
Tue Jan 19 04:59:22 UTC 2010


On 2010-01-18, at 8:23 PM, Andreas Raab wrote:

> It's not. Check the comment:
> 
> 	['true' asByteArray] -> ["Version 1.0 TTF file"
> 		"http://developer.apple.com/textfonts/TTRefMan/RM06/Chap6.html
> 		The values 'true' (0x74727565) and 0x00010000 are recognized by the Mac OS
> 		as referring to TrueType fonts."
> 		^Array with: 0 "only one font"
> 	].
> 
> Since this code has no performance implication whatsoever, I find 'true' asByteArray vastly more readable and intention revealing than  #[116 114 117 101].

It's more intention revealing, yes. What I don't like is that it relies on the unspecified semantics of #asByteArray. If the implementation of String changes (and it's happened once in recent history, so it's not just a "theoretical" worry), then you may not get the bytes you were expecting. 

The code above specifies the intention, but not the actual bytes required. The exact byte sequence is important though, enough so that the author felt the need to specify it in the comment. I'd rather see the exact bytes in the code, and the intention in the comment.

Colin


More information about the Squeak-dev mailing list