On 05/02/2012 08:21 AM, Paolo Bonzini wrote:
This little bit of magic is a bit too magical for my taste.
Polymorphism relies on the idea that a subclass overloads base class
members/methods. From the base classes perspective, it's unaware if
a subclass has overloaded something (that's allowed to be overloaded).
This code doesn't get the current class *as* the base class but rather gets the
non-overloaded form of the base class. This isn't really something
that most OO systems allow and I think it could lead to major ugliness in the
Not really, in fact this kind of class-side data is really bread and butter
of all dynamic languages, and it's how most of them implement polymorphism.
They have an associative array (method names -> method bytecode for example)
in each class on the hierarchy, and walk the hierarchy for each function call.
I'm not aware of any language that does this.
Many languages today have an associative array in the object. It's filled out
from a class definition during instantiation. This is what allows monkey patching.
Classes are first class objects and can contain members, but I don't know of any
system where you actively look at the same field in a super class for each class
in the hierarchy. That's really trippy.
If we move properties to Object, I'd rather just stick a property pointer in
TypeInfo and call it a day. I'm not thrilled about it, but I feel a lot better
about it the above.