From: Eric Blake <eblake@redhat.com>
To: Markus Armbruster <armbru@redhat.com>, Fam Zheng <famz@redhat.com>
Cc: Kevin Wolf <kwolf@redhat.com>,
Peter Maydell <peter.maydell@linaro.org>,
qemu-devel@nongnu.org, Michael Roth <mdroth@linux.vnet.ibm.com>,
Luiz Capitulino <lcapitulino@redhat.com>,
akong@redhat.com
Subject: Re: [Qemu-devel] [PATCH v2 2/2] qapi: Allow setting default values for optional parameters
Date: Mon, 05 May 2014 09:18:56 -0600 [thread overview]
Message-ID: <5367ABE0.6040104@redhat.com> (raw)
In-Reply-To: <8761lktrg3.fsf@blackfin.pond.sub.org>
[-- Attachment #1: Type: text/plain, Size: 1739 bytes --]
On 05/05/2014 05:06 AM, Markus Armbruster wrote:
>>
>> { 'command': 'block-commit',
>> 'data': { 'device': 'str', '*base': 'str', 'top': 'str',
>> '*speed': 'int' },
>> 'defaults': {'base': 'earthquake', 'speed': 100 } }
>>
>
> Can we keep a parameter's properties together? Perhaps like this:
>
> NAME: { 'type': TYPE, 'default': DEFAULT }
>
> where
>
> NAME: { 'type': TYPE }
>
> can be abbreviated to
>
> NAME: TYPE
I like it. It also means:
data: { '*foo': { 'type': 'str', 'default': 'hello' } }
is invalid - a defaulted argument is NOT spelled '*foo' but merely 'foo'.
>
> and
>
> NAME: { 'type': TYPE, 'default': null }
> to
>
> NAME-PREFIXED-BY_ASKTERISK: TYPE
>
> if we think these abbreviations enhance schema readability enough to be
> worthwhile. The first one does, in my opinion. but I'm not so sure
> about the second one.
Or, putting the question in reverse, you are asking if:
data: { '*foo': 'str' }
can blindly be rewritten into:
data: { 'foo': { 'type': 'str', 'default': null } }
and the rest of the introspection use the fact that 'default':null
implies that the argument is optional but has no specified default, and
therefore still needs the has_foo magic.
As you say, it's a bit more of a stretch, but does make introspection
nice (introspection already has to deal with leading '*' to turn it into
something nicer to pass over the wire - if we ever get introspection
working). I'd have to see it actually coded up to decide for sure if it
turned out to be a net win.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]
next prev parent reply other threads:[~2014-05-05 15:19 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1398764656-27534-1-git-send-email-famz@redhat.com>
[not found] ` <1398764656-27534-2-git-send-email-famz@redhat.com>
[not found] ` <535F9E40.8010407@redhat.com>
2014-05-05 8:33 ` [Qemu-devel] [PATCH v2 1/2] qapi: Allow decimal values Markus Armbruster
[not found] ` <1398764656-27534-3-git-send-email-famz@redhat.com>
[not found] ` <20140429112436.GE4835@noname.str.redhat.com>
[not found] ` <535FA06F.2060603@redhat.com>
2014-05-04 3:14 ` [Qemu-devel] [PATCH v2 2/2] qapi: Allow setting default values for optional parameters Fam Zheng
2014-05-05 9:51 ` Markus Armbruster
2014-05-05 15:13 ` Eric Blake
2014-05-05 11:06 ` Markus Armbruster
2014-05-05 15:18 ` Eric Blake [this message]
2014-05-05 17:34 ` Markus Armbruster
2014-05-05 23:03 ` Eric Blake
2014-05-06 9:55 ` Markus Armbruster
2014-05-06 12:35 ` Eric Blake
2014-05-06 15:09 ` Markus Armbruster
2014-05-06 1:30 ` Fam Zheng
2014-05-06 3:09 ` Eric Blake
2014-05-06 5:11 ` Fam Zheng
2014-05-06 11:57 ` Markus Armbruster
2014-05-06 11:53 ` Markus Armbruster
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5367ABE0.6040104@redhat.com \
--to=eblake@redhat.com \
--cc=akong@redhat.com \
--cc=armbru@redhat.com \
--cc=famz@redhat.com \
--cc=kwolf@redhat.com \
--cc=lcapitulino@redhat.com \
--cc=mdroth@linux.vnet.ibm.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).