[squeak-dev] Character space and literal arrays
Eliot Miranda
eliot.miranda at gmail.com
Wed Sep 22 21:10:07 UTC 2010
Hi Lukas,
there's a problem with the current printOn:/storeOn: distinction in
current Squeak. The issue is that within a literal Array all characters
must be printed using the $ form, /not/ the Character message or (Character
value: N) forms. e.g.
#($ ) storeString => #(Character space)
(Compiler evaluate: #($ ) storeString) size => 2
(Compiler evaluate: #($ ) storeString) = #(#Character #space) => true
In VisualWorks (7.7) the above works correctly (*)
#($ ) storeString => #($ )
(Compiler evaluate: #($ ) storeString) size => 1
(Compiler evaluate: #($ ) storeString) = #(#Character #space) => false
and works because Array asserts the "characters print literally" stream
policy while printing literally.
I stumbled upon this looking at the decompiler tests, specifically of
MethodPragmaTest>>testCompileCharacter:
testCompileCharacter
self assertPragma: 'foo: $a' givesKeyword: #foo: arguments: #( $a ).
self assertPragma: 'foo: $ ' givesKeyword: #foo: arguments: #( $ ).
which decompiled shows as
testCompileCharacter
self
assertPragma: 'foo: $a'
givesKeyword: #foo:
arguments: #($a ).
self
assertPragma: 'foo: $ '
givesKeyword: #foo:
arguments: #(Character space )
(*) but VW still has a bizarre def for printString,
(Array with: Character space) printString '#(Core.Character space)'
(Compiler evaluate: (Array with: Character space) printString) size => 2
best
Eliot
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20100922/8031cead/attachment.htm
More information about the Squeak-dev
mailing list
|