Hi folks!
Just can't resist. :)
Noury Bouraqadi bouraqadi@ensm-douai.fr wrote:
Stef,
In PocketSmalltalk globals are replaced by class variables in Object... But, in PocketSmalltalk there is a set of things done behind the scene developpers don't seem to have access to them.
Now, if we make the decision to remove gloabals we need to bootstrap the system somehow. Eg. how will we kow that Smalltalk refers to the global system dictionary?
Actually, I didn't think a lot about it. But, I have the feeling that we still need globals but need some extra scoping hierarachical mechanism: a kind of namespaces where the root namespace would named... Smalltalk...
Noury
Well, my Namespace package on SM allows this. I just installed it into 3.8-6465, and played with it. Read the class comment of Namespace, and then you can try these steps in a workspace:
"Let's create a namespace for globals:" Namespace newNamed: #Globals
"And put the Transcript in there:" Globals at: #Transcript put: Transcript
"Here we can see it has been added:" Globals keys ==> a Set(#Transcript)
"It is still also referenced in Smalltalk though:" (Smalltalk at: #Transcript) == Globals::Transcript ==> true
"Given how my namespaces work we have two keys in Smalltalk now:" Smalltalk keys select: [:k | k endsWith: 'Transcript'] ==> an IdentitySet(#Globals::Transcript #Transcript)
"So let's toast the old entry!" Smalltalk removeKey: #Transcript
"Now this should work:" Globals::Transcript show: 'Hi!'
"But this also still works! It gets expanded to Globals::Transcript:" Transcript show: 'Hi'
"So if you recompile a method that looks like this:" method Transcript show: 'Hi'. Globals::Transcript show: ' there!'
"It will autocontract because there is just one entry (in all Namespaces) that is called Transcript so the short name still fully identifies it." method Transcript show: 'Hi'. Transcript show: ' there!'
"But if you decompile it, you will see that it actually says this in the stored source:" method Globals::Transcript show: 'Hi'. Globals::Transcript show: ' there!'
---- Note though that the Namespace package is not fully working yet. But it is sufficiently working that you can play with it using a helmet.
regards, Göran