On 23 nov. 2013, at 20:58, Hernán Morales Durand <[email protected]> wrote:
> Hi Camille, > > What is an anonymous class for you? because it could refer to a lightweight > class or a metaclass... A class that is not installed in the system dictionary, typically generated. As pointed by Igor, that's not a very good name since such a class does have a name, it's just not accessible by simply using that name in code, you need to have a reference to it. However, as pointed by Eliot, that's the name used for two decades now. So in the end, metaclasses are more anonymous than anonymous classes :D > > Cheers, > > Hernán > > El 22/11/2013 12:04, Camille Teruel escribió: >> 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? >> >> >> . >> > >
