Binding semantics of SystemDictionary
Hi Tommaso and I, while hacking on Fuel, today discovered that globals in Pharo can have very weird bindings (I guess some of you already know that). For example: class := Class new setName: 4; yourself. Smalltalk at: class name put: class. So we now have a class with name 4 (which is a SmallInteger): self assert: (Smalltalk at: 4) == class. There are basically two different issues: 1. SystemDictionary will store any kind of association, not only symbols / strings 2. SystemDictionary is an IdentityDictionary and as such two equivalent but not identical keys will not resolve to the same object: class := Class new setName: (String streamContents: [ :s | s nextPutAll: 'someName']); yourself. Smalltalk at: class name put: class. Smalltalk at: (String streamContents: [ :s | s nextPutAll: 'someNameâ]) ifAbsent: [ false ]. âââ> falseâ In Fuel we simply assume that any key to a global is either a ByteString or ByteSymbol. If thatâs not the case bad things happen. It would help us a lot if we could clear up the semantics of bindings in SystemDictionary: 1. Are bindings with keys that are not ByteString or ByteSymbol valid? 2. Should we keep allowing ByteString as keys to globals (ByteSymbol guarantees identity)? 3. If we allow ByteString, do we also allow WideString? 4. Would âtype checksâ on SystemDictionary incur a big performance penalty? Any suggestions are welcome. Cheers, Max
not only the globals but the methods in MethodDictionary too :) It might be a feature, it's just that it's unused because of limited IDE and compiler. 2015-03-31 20:49 GMT+02:00 Max Leske <maxleske@gmail.com>:
Hi
Tommaso and I, while hacking on Fuel, today discovered that globals in Pharo can have very weird bindings (I guess some of you already know that). For example:
class := Class new setName: 4; yourself. Smalltalk at: class name put: class.
So we now have a class with name 4 (which is a SmallInteger):
self assert: (Smalltalk at: 4) == class.
There are basically two different issues: 1. SystemDictionary will store any kind of association, not only symbols / strings 2. SystemDictionary is an IdentityDictionary and as such two equivalent but not identical keys will not resolve to the same object:
class := Class new setName: (String streamContents: [ :s | s nextPutAll: 'someName']); yourself. Smalltalk at: class name put: class.
Smalltalk at: (String streamContents: [ :s | s nextPutAll: 'someNameâ]) ifAbsent: [ false ]. âââ> falseâ
In Fuel we simply assume that any key to a global is either a ByteString or ByteSymbol. If thatâs not the case bad things happen. It would help us a lot if we could clear up the semantics of bindings in SystemDictionary: 1. Are bindings with keys that are not ByteString or ByteSymbol valid? 2. Should we keep allowing ByteString as keys to globals (ByteSymbol guarantees identity)? 3. If we allow ByteString, do we also allow WideString? 4. Would âtype checksâ on SystemDictionary incur a big performance penalty?
Any suggestions are welcome.
Cheers, Max
On 31 Mar 2015, at 23:12, Nicolas Cellier <nicolas.cellier.aka.nice@gmail.com> wrote:
Thanks Nicolas. I was hoping to see a bit more activity on this thread so I didnât reply immediately.
not only the globals but the methods in MethodDictionary too :)
Ok, that might even be worse. AFAIK MethodDictionary is treated as a special class by the VM. So storing other objects in there may be a real problem, not just a philosphical one. CCâing vm-dev on this.
It might be a feature, it's just that it's unused because of limited IDE and compiler.
If you look far enough, almost anything can be considered a feature⦠:)
2015-03-31 20:49 GMT+02:00 Max Leske <maxleske@gmail.com <mailto:maxleske@gmail.com>>: Hi
Tommaso and I, while hacking on Fuel, today discovered that globals in Pharo can have very weird bindings (I guess some of you already know that). For example:
class := Class new setName: 4; yourself. Smalltalk at: class name put: class.
So we now have a class with name 4 (which is a SmallInteger):
self assert: (Smalltalk at: 4) == class.
There are basically two different issues: 1. SystemDictionary will store any kind of association, not only symbols / strings 2. SystemDictionary is an IdentityDictionary and as such two equivalent but not identical keys will not resolve to the same object:
class := Class new setName: (String streamContents: [ :s | s nextPutAll: 'someName']); yourself. Smalltalk at: class name put: class.
Smalltalk at: (String streamContents: [ :s | s nextPutAll: 'someNameâ]) ifAbsent: [ false ]. âââ> falseâ
In Fuel we simply assume that any key to a global is either a ByteString or ByteSymbol. If thatâs not the case bad things happen. It would help us a lot if we could clear up the semantics of bindings in SystemDictionary: 1. Are bindings with keys that are not ByteString or ByteSymbol valid? 2. Should we keep allowing ByteString as keys to globals (ByteSymbol guarantees identity)? 3. If we allow ByteString, do we also allow WideString? 4. Would âtype checksâ on SystemDictionary incur a big performance penalty?
Any suggestions are welcome.
Cheers, Max
Please do not use Smalltalk at: We will ban it for real! Stef Le 31/3/15 20:49, Max Leske a écrit :
Hi
Tommaso and I, while hacking on Fuel, today discovered that globals in Pharo can have very weird bindings (I guess some of you already know that). For example:
class := Class new setName: 4; yourself. Smalltalk at: class name put: class.
So we now have a class with name 4 (which is a SmallInteger):
self assert: (Smalltalk at: 4) == class.
There are basically two different issues: 1. SystemDictionary will store any kind of association, not only symbols / strings
arghhhh
2. SystemDictionary is an IdentityDictionary and as such two equivalent but not identical keys will not resolve to the same object:
class := Class new setName: (String streamContents: [ :s | s nextPutAll: 'someName']); yourself. Smalltalk at: class name put: class.
Smalltalk at: (String streamContents: [ :s | s nextPutAll: 'someNameâ]) ifAbsent: [ false ]. âââ> falseâ
In Fuel we simply assume that any key to a global is either a ByteString or ByteSymbol. If thatâs not the case bad things happen. It would help us a lot if we could clear up the semantics of bindings in SystemDictionary: 1. Are bindings with keys that are not ByteString or ByteSymbol valid? 2. Should we keep allowing ByteString as keys to globals (ByteSymbol guarantees identity)? 3. If we allow ByteString, do we also allow WideString? 4. Would âtype checksâ on SystemDictionary incur a big performance penalty?
Any suggestions are welcome.
Cheers, Max
Bump⦠I really think this is something we should talk about⦠Otherwise Iâll open an issue on phogbugz.
On 01 Apr 2015, at 22:58, stepharo <stepharo@free.fr> wrote:
Please do not use Smalltalk at: We will ban it for real!
Good to know. I wasnât aware of that.
Stef
Le 31/3/15 20:49, Max Leske a écrit :
Hi
Tommaso and I, while hacking on Fuel, today discovered that globals in Pharo can have very weird bindings (I guess some of you already know that). For example:
class := Class new setName: 4; yourself. Smalltalk at: class name put: class.
So we now have a class with name 4 (which is a SmallInteger):
self assert: (Smalltalk at: 4) == class.
There are basically two different issues: 1. SystemDictionary will store any kind of association, not only symbols / strings
arghhhh
Exactly the sound I made when we discovered that :)
2. SystemDictionary is an IdentityDictionary and as such two equivalent but not identical keys will not resolve to the same object:
class := Class new setName: (String streamContents: [ :s | s nextPutAll: 'someName']); yourself. Smalltalk at: class name put: class.
Smalltalk at: (String streamContents: [ :s | s nextPutAll: 'someNameâ]) ifAbsent: [ false ]. âââ> falseâ
In Fuel we simply assume that any key to a global is either a ByteString or ByteSymbol. If thatâs not the case bad things happen. It would help us a lot if we could clear up the semantics of bindings in SystemDictionary: 1. Are bindings with keys that are not ByteString or ByteSymbol valid? 2. Should we keep allowing ByteString as keys to globals (ByteSymbol guarantees identity)? 3. If we allow ByteString, do we also allow WideString? 4. Would âtype checksâ on SystemDictionary incur a big performance penalty?
Any suggestions are welcome.
Cheers, Max
participants (3)
-
Max Leske -
Nicolas Cellier -
stepharo