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: Paolo Bonzini
Subject: Re: [Qemu-devel] [PATCH 11/21] qdev: move bus properties to abstract superclasses
Date: Wed, 02 May 2012 09:21:54 -0400 (EDT)

> 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.
Doing method lookups like that is not something we can do in C of course, but
for data it's perfectly fine IMHO.

> I much prefer moving property installation to a function call that is
> invoked during base class init.

That leaves you without the possibility to inspect static property info,
unless you do the gross-ish hack of calling object_new and immediately
freeing the object.

Paolo



reply via email to

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