All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: Markus Armbruster <armbru@redhat.com>
Cc: Kevin Wolf <kwolf@redhat.com>,
	Peter Maydell <peter.maydell@linaro.org>,
	Fam Zheng <famz@redhat.com>,
	Michael Roth <mdroth@linux.vnet.ibm.com>,
	qemu-devel@nongnu.org, 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 17:03:06 -0600	[thread overview]
Message-ID: <536818AA.50101@redhat.com> (raw)
In-Reply-To: <87iopkdt9g.fsf@blackfin.pond.sub.org>

[-- Attachment #1: Type: text/plain, Size: 2443 bytes --]

On 05/05/2014 11:34 AM, Markus Armbruster wrote:
>>
>> 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.
> 
> Glad you mention introspection; I didn't think of it.
> 
> The "an asterisk at the beginning of a name is not part of the name, but
> means the parameter is optional" thing is a deviation from our usual
> design rule against parsing strings in addition to JSON.  My proposal to
> make the "is optional" property an ordinary JSON member straightens this
> out.
> 
> The bit I'm not sure about is whether we want to keep the
> NAME-PREFIXED-BY-ASKTERISK: TYPE form as syntactic sugar.

Keeping it as sugar in the input .json files seems reasonable.

Exposing it as sugar in introspection is a bad idea.

Keeping the input file easy to write, and more compact than what
introspection will output, is a fine tradeoff in my book (easier to
maintain if there is less to type; while still having a well-defined
conversion to the formal output form).

> 
> Keeping the TYPE: NAME form as sugar makes sense to me, because it cuts
> noise in the schema while adding no syntax beyond JSON.

Exactly - the point of syntactic sugar is to have a short form for
common usage, while having the full form when full expressiveness is
needed.  The .json schema files are internal use only; the introspection
QMP command is not yet written but can adapt to the ideas in this thread.

> 
> The schema parser desugars its input.  Sugaring schema introspection
> output makes no sense to me, because all that accomplishes is
> introspection users have to duplicate the schema parser's desugaring.

I think we're on the same page, then.

-- 
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 --]

  reply	other threads:[~2014-05-05 23:03 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
2014-05-05 17:34       ` Markus Armbruster
2014-05-05 23:03         ` Eric Blake [this message]
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=536818AA.50101@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.