On 26 ao�t 2013, at 13:31, Igor Stasenko wrote:
the intent was to replace
Smalltalk at:
Smalltalk globals at:
idioms with shorter one, and get rid of referencing Smalltalk global.
The are not for solving future problems with introduction of environments.
We want to get rid of Smalltalk globals because it currently resolve to an instance of SmalltalkImage, a class that does way too much things, including holding the currently unique environment, while a global could directly refer to it.
Also the references to Smalltalk globals that where really wrong are already gone and were in compiler.
And even if you introduce them, i still think you need a way to refer to globals (they are likely to stay)
Globals are global to their environment. We could also call them environment variable.
Whatever we will use for binding symbols in local environment, this is orthogonal.
Now you proposing introduce
ThisEnvironment at:
which getting back where we started from.
No because ThisEnvironment would be an instance of Environment (basically a refactored SystemDictionary) not of SmalltalkImage.
So who should be in charge of knowing how to handle accessible variable?
An instance of Environment with a nice api or an instance of Symbol by herself?
Unless , in your vision ThisEnvironment handled by compiler (like thisContext)..
so there will be no new global, but ThisEnvironment bound at compile time.
anyways, it will be semantically different from what we have now,
it will lookup for symbol in local environment, instead of global one.
ThisEnvironment would not be different than any other global.
There is no semantic change, no magic, nothing.
That's what the compiler already does.
The compiler use the environment of the class of the method being compiled to resolve globals.
It happens that all classes currently share the same environment, that's something else.
And this is not going to happen (you cannot replace
Smalltalk globals at: with ThisEnvironment at: without overlooking all the places where it used)...
while replacing it with #asClass is fine (because semantics stays same).
Also, #asClass means 'give me the class or throw error', while
Smalltalk globals at: , obviously don't do that and gives you any object bound to given symbol, if it there.
Any control?
at:ifAbsent:
at:ifPresent:
at:ifAbsent:ifPresent:
are already there and if you want to ensure the global is a class you could have: classNamed:ifAbsent:ifPresent: