Where are system globals (Smalltalk and SystemOrganization)
Boris Gaertner
Boris.Gaertner at gmx.net
Wed Dec 8 21:51:32 UTC 2004
From: "Aaron Gray" <angray at beeb.net>
> Are Smalltalk and SystemOrganization "global variables".
Yes, they are.
> If so where are the
> system globals and how do I list them, within a browser and say to the
> Transaction window from the workspace ?
All the globals are in Smalltalk, which is an instance of
SystemDictionary.
Evaluate the following statements with print to obtain
a feeling for this:
Smalltalk class
Smalltalk includesKey: #Smalltalk
Smalltalk includesKey: #SystemOrganization
Smalltalk is also the Dictionary that contains all classes.
That is OK, classes are globally defined entities, too.
Now, what you are really after is that:
Smalltalk reject: [:item | item class isMeta ]
Evaluate it with 'inspect'
This opens an inspector that shows you all globals that
are not classes. (see footnote ** below)
Here is exactly what you want:
(Smalltalk reject: [:item | item class isMeta ])
associationsDo: [:assoc | Transcript show: assoc key printString; cr].
This prints the names of the non-class globals into the transcript window.
Note that (Smalltalk reject: [:item | item class isMeta ])
answers selected associations from Smalltalk.
With
associationsDo: [:assoc | Transcript show: assoc key printString; cr].
we print only the keys of the assocs, the values of some globals
have huge printed representations; it is therefore not a good idea
to write them into the transcript.
**) The 'class isMeta' looks like magic, but it is not.
isMeta is defined in the instance protocol of classes
Behavior and MetaClass. The class of a class is an instance of MetaClass,
when sent the message isMeta, it answers true. Classes answer
false.
Greetings,
Boris
More information about the Squeak-dev
mailing list
|