[squeak-dev] Questions about Environments
Levente Uzonyi
leves at elte.hu
Sun Jun 9 16:16:29 UTC 2013
Hi,
I started rewriting Environments to use a different kind of dictionary,
which won't get into an inconsistent state when a binding is modified.
The rewrite is almost ready, but I still don't understand a few things:
1) Some methods use the instance variable 'references' to look up
bindings, others use 'declarations'. After the rewrtie some tests don't
pass, because the bindings don't get added to 'references', but they are
present in 'declarations', so using the latter will make the tests pass.
According to the class comment:
declarations <IdentityDictionary>
Bindings for globals that have been declared inside me
references <IdentityDictionary>
Bindings for globals that are used by methods compiled inside me.
Which suggests that neither 'declarations', nor 'references' are good
enough for lookup in case of #associationAt:, #associationAt:ifAbsent: or
#associationOrUndeclaredAt:, #at:, #at:if*:, etc.
There either need to be a dictionary which contains all the bindings
visible from the Environment, or the class comment is wrong and
'declarations' is exactly that. In the latter case 'references' seems to
be superfluous to me.
2) The only way for a binding to get into 'references' is to get into
'imports' first and get copied to 'references' in #bindingOf:ifAbsent:.
But how does a newly compiled class's binding get into 'imports'?
And why does that happen? The class comments suggests that only referenced
(used by some methods) classes' bindings get into 'references', but new
classes are not referenced by any method.
3) There are multiple classes being used for bindings including:
ClassBinding, Global, Alias and Association (all bindings created in
Undeclared are Associations, since it's a simple IdentityDictionary).
The type of these bindings can change. Sometimes a class is created from a
global (Global->Class) or a class gets declared (Association->Class), etc
In these cases the class of the bindings should follow these changes. But
AFAIK that's not happening now, and those would require a #becomeForward:
send, which is rather slow. We could address these if the type of the
binding would be stored in an instance variable, but that's a bit less
flexible. Any ideas what to do with these?
Cheers,
Levente
More information about the Squeak-dev
mailing list
|