in reply to Re: Help with Metaclasses
in thread Help with Metaclasses
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Help with Metaclasses
by tall_man (Parson) on Oct 19, 2004 at 22:57 UTC |