As you investigate, perhaps by googling for "metaclass", beware that the Python and Perl usage of the term is starkly different from the Smalltalk meaning.

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.


In reply to •Re: Help with Metaclasses by merlyn
in thread Help with Metaclasses by Boots111

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.