One we did for Pharo4 is to use the Associations of Globals to model these variables as meta-objects (in the same spirit as the Slot objects).
Thos means that
-> there is an Api to get them
-> they have an API to read /write
This is just ���sugar��� on what the associations did already:
global := SmalltalkImage classVariableNamed: #CompilerClass.
global read.
global class
==> ClassVariable
Then, I added that the Compiler actually delegates code generation for read and write
to these meta-objects, meaning you can subclass them and add special kinds of Globals
with special semantics (just like Slot Subclasses). This could be used for e.g.active globals
that announce when changed.
But the real use-case for this is putting meta-links on these globals.
e.g. add a class TT with class var T and a method that reads it.
|link |
link := MetaLink new
metaObject: Halt;
selector: #now.
(TT classVariableNamed: #T) link: link.
TT new readT
-> halt.
This means that we can out break-points on class variables (as opposed to a single read or write).
This all needs a bit more work to be really usable���
Marcus