[squeak-dev] SmalltalkImage current vs Smalltalk: Option #3

Andreas Raab andreas.raab at gmx.de
Fri Mar 5 04:24:23 UTC 2010


Folks -

I've been working on this stuff a little now and (as always) things look 
different once you actually dug into it. There is a really interesting 
option here which I'd like to propose as option #3 since it does require 
a bit of refactoring but it makes good sense to me:

* Move methods from SystemDictionary to SmalltalkImage.
* Make SmalltalkImage current == Smalltalk.
* Make Smalltalk globals class == SystemDictionary

So far we're still with option #2, but now it gets interesting:

* Use Smalltalk globals as Behavior>>environment, i.e.,

Behavior>>environment
	"Return the environment in which the receiver is visible"
	^Smalltalk globals

* Remove any non-dictionary stuff from SystemDictionary; fix all 
non-dictionary uses of "self environment" (VERY few; much less than I 
expected)

* Remove all the dictionary methods from SmalltalkImage except #at:, 
#at:ifAbsent:, #at:ifPresent: (there simply are too many users of those 
to get rid of it but it avoids literally some 20+ methods that are 
required otherwise)

The result is that:
1) Smalltalk == SmalltalkImage current
2) Smalltalk class == SmalltalkImage
3) Smalltalk globals class == SystemDictionary
4) SomeClass environment == Smalltalk globals

Interestingly, this is pretty much the way these entities are already 
used; just not consistently. After browsing through quite a bit of code 
that does feel like the most natural separation - the environment as the 
dictionary / namespace; Smalltalk as the system-wide facade for various 
things.

What do you think?

Cheers,
   - Andreas



More information about the Squeak-dev mailing list