qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 11/21] qdev: move bus properties to abstract sup


From: Anthony Liguori
Subject: Re: [Qemu-devel] [PATCH 11/21] qdev: move bus properties to abstract superclasses
Date: Wed, 02 May 2012 15:00:55 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:11.0) Gecko/20120329 Thunderbird/11.0.1

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
future.

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.

Regards,

Anthony Liguori




reply via email to

[Prev in Thread] Current Thread [Next in Thread]