From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:56703) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SPfkX-0006UT-PR for qemu-devel@nongnu.org; Wed, 02 May 2012 16:02:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SPfkV-0002QC-RG for qemu-devel@nongnu.org; Wed, 02 May 2012 16:02:09 -0400 Received: from e9.ny.us.ibm.com ([32.97.182.139]:39817) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SPfkV-0002LM-Mm for qemu-devel@nongnu.org; Wed, 02 May 2012 16:02:07 -0400 Received: from /spool/local by e9.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 2 May 2012 16:01:31 -0400 Received: from d01relay01.pok.ibm.com (d01relay01.pok.ibm.com [9.56.227.233]) by d01dlp01.pok.ibm.com (Postfix) with ESMTP id A756B38C806F for ; Wed, 2 May 2012 16:01:23 -0400 (EDT) Received: from d01av03.pok.ibm.com (d01av03.pok.ibm.com [9.56.224.217]) by d01relay01.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q42K1Nm7030404 for ; Wed, 2 May 2012 16:01:23 -0400 Received: from d01av03.pok.ibm.com (loopback [127.0.0.1]) by d01av03.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q42K11L2008536 for ; Wed, 2 May 2012 17:01:01 -0300 Message-ID: <4FA19277.2030209@us.ibm.com> Date: Wed, 02 May 2012 15:00:55 -0500 From: Anthony Liguori MIME-Version: 1.0 References: <2474f1d2-b6e2-475b-a45e-2fadf28625e5@zmail13.collab.prod.int.phx2.redhat.com> In-Reply-To: <2474f1d2-b6e2-475b-a45e-2fadf28625e5@zmail13.collab.prod.int.phx2.redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 11/21] qdev: move bus properties to abstract superclasses List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: peter maydell , qemu-devel@nongnu.org, afaerber@suse.de, liwp@linux.vnet.ibm.com 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