qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] Re: [PATCH 01/10] Introduce qmisc module


From: Paolo Bonzini
Subject: Re: [Qemu-devel] Re: [PATCH 01/10] Introduce qmisc module
Date: Sun, 18 Oct 2009 17:25:47 +0200
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.4pre) Gecko/20091014 Fedora/3.0-2.8.b4.fc11 Lightning/1.0pre Thunderbird/3.0b4


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.

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.

  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.

Paolo




reply via email to

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