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
|
something old like http://bugs.squeak.org/view.php?id=4322
http://bugs.squeak.org/view.php?id=5700 Nicolas 2010/9/22 Eliot Miranda <[hidden email]>: > 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 > > > |
In reply to this post by Eliot Miranda-2
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 <[hidden email]> 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 |
Free forum by Nabble | Edit this page |