Problem with symbol interning
Tony Garnock-Jones
tonyg at lshift.net
Wed Jun 7 11:55:09 PDT 2006
The problem:
(#as: findOn: {'a'. Symbol}) ~= (#as: findOn: {String. Symbol})
and thus
('a' as: Symbol) ~= ('a' as: Symbol) "and"
('a' as: Symbol) ~= #a
Investigation:
Slate 22> (#as: findOn: {'a'. Symbol}) disassemble.
name: as:
inputs: 2
locals: 3
allocation: heap
rest parameter: False
optional keywords: (none)
0: loadSelector 0 #newSizeOf:
1: loadVariable 1
2: loadVariable 0
3: sendMessage 2
4: storeVariable 2
5: loadSelector 1 #doWithIndex:
6: loadVariable 0
7: newClosure 0
8: sendMessage 2
9: popStack 2
10: loadVariable 2
Nil
Slate 23> (#as: findOn: {String. Symbol}) disassemble.
name: as:
inputs: 2
locals: 2
allocation: stack
rest parameter: False
optional keywords: (none)
0: loadSelector 0 #intern
1: loadVariable 0
2: sendMessage 1
Nil
The first one is the bogus one, the second one is the one I was
expecting to be invoked. Grepping for newSizeOf with "-C 3" gives our
culprit(s):
--
src/lib/string.slate-s@(ASCIIString traits) as: a@(ByteArray traits)
src/lib/string.slate-"Since ByteArrays cannot hold objects, they must
store character codes."
src/lib/string.slate-[| newA |
src/lib/string.slate: newA: (a newSizeOf: s).
src/lib/string.slate- s doWithIndex:
src/lib/string.slate- [| :each :index | newA at: index put: (each as:
a elementType)].
src/lib/string.slate- newA
--
src/lib/string.slate-a@(ByteArray traits) as: s@(ASCIIString traits)
src/lib/string.slate-"Since ByteArrays cannot hold objects, they must
store character codes."
src/lib/string.slate-[| newS |
src/lib/string.slate: newS: (s newSizeOf: a).
src/lib/string.slate- a doWithIndex:
src/lib/string.slate- [| :each :index | newS at: index put: (each as:
s elementType)].
src/lib/string.slate- newS
--
So, somehow the inheritance on String and/or Symbol is messed up enough
that one of the two methods above are being called instead of (String
as: Symbol) as defined in symbol.slate.
Tony
More information about the Slate
mailing list