Don't think this is the same thing what the OP is talking about.

To be frank, Perl does not provide the metaclass as provided in Python. Class:Struct is nothing more than a way to define a c-alike struct, which Perl lacks of (and I doubt we really need, with OO there. With OO, even c++ no longer needs struct as c did).

"In C++ genericity is covered by templates. In perl, that sort of thing is far less necessary because of no static typing."

That is again nothing close to Python's metaclass. The template concept in C++, in simply a patch to the language, so that it can provide the powerful STL, to match up with java's utility classes.

In Java, it has whole bunch of utility classes, like Vector, Hashtable..., their elements are all simply declared as Object, which is everything and anything. C++ does not have this Object class, so it came up this template concept, which allows you to define things like LinkedList just once for whatever kind of element, and just resolve it at compilation time.

However it is still not the same as in Java. Once you say something like LinkedList<int>, all the elements in that linked list are now nothing else but int. But in Java, it is not the same case, a Java Hashtable can contain anything, and element 0 can be of class BLAH, when element 1 might be of class YAHOO.

A Perl hash or array has the similar nature as java's hahtable etc., however because of different reasons: in java, it is becasue of the Object base class; in Perl, it is not because of the UNIVERSAL base class, but becasue Perl is not a "strong type" language.


In reply to Re^2: Help with Metaclasses by pg
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.