in reply to Help with Metaclasses
In Smalltalk, the Metaclass is an instance of the Metaclass class that holds the methods used by the specific Class (of which it is the sole instance of the Metaclass), which in turn holds the methods for a specific instance. Got that? {grin}
For instance (ugh), (and simplifying a bit), you create a new Array by sending "new" to the Array class, which invokes the method whose definition is found (by inheritance) in the method dictionary of the metaclass of Array. Once you have a specific Array, methods sent to it are looked up in the dictionary held in Array (and its parent classes).
So, in Smalltalk, a Metaclass provides behaviors for a Class, and a Class provides behaviors for an instance. (Do I dare bring up that both Class and Metaclass are themselves classes, so they both have classes and metaclasses that are instances of themselves and each other? Ouch!)
By contrast, Perl has only a symbol table (package) that provides behaviors for both classes and instances, distinguished by the first parameter (class methods have the class name, instance methods have the instance reference). The term "metaclass" (which I've not heard much in Perl) as you reference it seems to refer to "metaprogramming" instead: creating code that creates code.
-- Randal L. Schwartz, Perl hacker
Be sure to read my standard disclaimer if this is a reply.
|
|---|