From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MzYGZ-0003sT-H5 for qemu-devel@nongnu.org; Sun, 18 Oct 2009 12:05:55 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MzYGU-0003q2-Hw for qemu-devel@nongnu.org; Sun, 18 Oct 2009 12:05:54 -0400 Received: from [199.232.76.173] (port=54848 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MzYGT-0003pw-TP for qemu-devel@nongnu.org; Sun, 18 Oct 2009 12:05:50 -0400 Date: Sun, 18 Oct 2009 14:05:35 -0200 From: Luiz Capitulino Subject: Re: [Qemu-devel] Re: [PATCH 01/10] Introduce qmisc module Message-ID: <20091018140535.17eca067@doriath> In-Reply-To: <4ADB337B.7080803@gnu.org> References: <1255037747-3340-1-git-send-email-lcapitulino@redhat.com> <1255037747-3340-2-git-send-email-lcapitulino@redhat.com> <4AD72B88.2040107@codemonkey.ws> <20091015122622.1f93ea2d@doriath> <20091015163936.GB532@redhat.com> <20091015142837.6c90580a@doriath> <4AD76B3C.3050001@codemonkey.ws> <4AD87424.3010000@redhat.com> <4AD87901.5030705@codemonkey.ws> <4AD8AECE.9000507@redhat.com> <4AD8AFA4.4070203@codemonkey.ws> <4AD8CB31.9080809@redhat.com> <4AD8E7B5.8000509@codemonkey.ws> <4AD910BA.4090607@gnu.org> <4AD922EB.5030501@codemonkey.ws> <4AD995FD.6070202@snarc.org> <20091018120631.0ab44d80@doriath> <4ADB2172.2040501@gnu.org> <4ADB2B13.4090207@codemonkey.ws> <20091018131818.6d8d73ae@doriath> <4ADB337B.7080803@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: Vincent Hanquez , qemu-devel@nongnu.org On Sun, 18 Oct 2009 17:25:47 +0200 Paolo Bonzini wrote: > > >> I'd strongly suggest making the JSON encoder live outside of QObject. > >> There are many possible ways to represent a QObject. Think of JSON as a > >> view of the QObject model. The human monitor mode representation is a > >> different view. > > My rationale was that since QObject is tailored over JSON, we might as > well declare JSON to be "the" preferred view of the QObject model. Maybe this makes sense today as the Monitor is the only heavy user of QObjects, but I don't think we should count on that. As things evolve, I believe more subsystems will start using QObjects and any "particular" view of it will make little sense. To be honest I don't know if this is good, I fear we will end up enhancing QObjects to the extreme to do OOP in QEMU... > The human monitor representation would be provided by qstring_format in > my patches (and a QError method would call qstring_format in the > appropriate way, returning a C string with the result). > > I think the different opinions is also due to different background; mine > is in Smalltalk where class extensions---aka monkeypatching---are done > in a different style than for example in Python. Adding a "write as > escaped JSON" method to QString would be akin to monkeypatching. True. > > I agree. > > > > QObject's methods should only be used/needed by the object layer itself, > > if the problem at hand handles high level data types (QInt, QDict, etc) > > then we need a new type. > > > > The right way to have what Paolo is suggesting, would be to have a > > toString() method in the object layer and allow it to be overridden. > > That's exactly what I did in my patches, except I called it encode_json > rather than toString. Okay, I just took a quick look at them and am looking at Anthony's right now. Anyway, my brainstorm on this would be to have to_string() and have default methods on all types to return a simple string representation. The QJson type could override to_string() if needed, this way specific json bits stays inside the json module. But I see that Anthony has added a qjson type already..