[squeak-dev] Re: Character space and literal arrays

Lukas Renggli renggli at gmail.com
Wed Sep 22 21:22:39 UTC 2010


Hi Eliot,

Indeed, this looks like a issue.

Interestingly the refactoring browser avoids the problem and
implements its own code for printing character literals.

So you suggest to replace Character>>#storeOn: with

Character>>#storeOn: aStream
   aStream nextPut: $$; nextPut: self

?

However this will break again if the character is not supported in aStream.

Lukas

On 22 September 2010 23:10, Eliot Miranda <eliot.miranda at gmail.com> wrote:
> 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



-- 
Lukas Renggli
www.lukas-renggli.ch



More information about the Squeak-dev mailing list