|
| Since this paper was never completed I'm not responsible for the errors that lurk, however if you find some please email me. Why it wasn't completed is another story. and understanding all this did pay off.
Nov 2000. Ira Forman was kind enough to send some comments, so I've made some corrections. MetaClassesSince this is a review for some readers, I suggest they skip ahead to the discussion about New allocation logic. For others, please open up an image and browse the String class. Notice that its superclass is CharacterArray. Browsing CharacterArray and its superclass, you eventually work your way up a hierarchy to the class Object. Different Smalltalk vendors will have different hierarchies, but most of the following should apply for any vendor that adheres to the proposed ANSI standard. Every object is ultimately a subclass of Object (the wary reader should note that some Smalltalk systems might have classes that don't lead to Object). Now inspect the object String class. Both a VisualWorks and VisualAge inspector window will have the title Metaclass. This object is known as the String class's metaclass. Metaclasses are an important concept. When you create a new class, one instance of a Metaclass is created to contain the class's attributes, behavior and implementation. Class methods and class variables DO need to be stored somewhere. This follows the rule that all objects in the image are instances of a class. Evaluating Metaclass instanceCount in a basic VW image produces an answer of 964 . This means 964 classes are defined in the image. Metaclasses of course have superclasses, and they mirror the same hierarchy as instances. One important difference occurs at the Object class namely...
Figure A. Class and instance hierarchy Normally for any object obj the rule obj class superclass == obj superclass class, is followed until we get to Object. The rule followed (Ira Forman: Putting Metaclasses to Work (Addison-Wesley 1999) is: The metaclass for a class must be below or equal to the metaclass for each of its direct superclasses. Inspect Object class superclass. The answer Class is given, and not nil, as one would first think. Object superclass class on the other hand points to the UndefinedObject class, better known as the class that created the instance nil. Both these cases are evident in figure A. Object points to nil, and Object Class has an arrow that wraps around to the left to point to Class. The Class class is the abstract superclass of all metaclasses, and provides the interface point of logic that allows you to create classes in the image. Class class is not the termination point . It is a subclass of other abstract classes. After evaluating Class class superclass, we work our way up a hierarchy Class->ClassDescription-> Behavior just before returning to class Object. Object is the superclass of all instances as well as all metaclasses. This follows from the key definition that Object is the ultimate superclass of all entities in your image, barring exceptions found in some unusual applications. { 1990 note such as proxies } |