Hi everyone,
With Esteban, we bumped into a problem with anonymous subclasses and the slot
class builder.
The problem is that once an anonymous class is created is not possible to
modify it.
Here is the problem:
For creating an anonymous class with the new class builder API you do something
like:
myAnonymousClass := AnonymousClassInstaller make: [ :classBuilder |
classBuilder
superclass: Object;
name: #MyAnonymousClass;
.... ]
What happens is that the class builder asks the class installer if the class
named #MyAnonymousClass exists or not to know if this a class to be created or
to be modified.
Here, the strategy of the anonymous class installer is to always answer no. So
ok, now you have you're anonymous class.
But what happens when you do something like:
myAnonymousClass addInstVarNamed: #newIV
Since the class has no clue of what class installer was used to create it, it
instantiate a new one, and a PharoClassInstaller !
This new class installer then says to the class builder that there is no class
named MyAnonymousClass so it creates it! And it install it in the system
dictionary!
And myAnonymousClass is not modified.
So there is several problem here:
- a class doesn't know which class installer was used to create it
- even if the class would know that, the anonymous class installer would always
say that it doesn't know it and a new class would be created
So one possible solution for that is to have one class installer per
environment (so add one iv in SystemDictionary right now), like that a class
would know what class installer was used to create it.
What would happen then is that you don't create anonymous classes anymore, that
is to say a class not installed in any environment, but instead you create a
class that exist in an environment separated from the system dictionary.
What do you think?