Received: from eggs.gnu.org ([2001:4830:134:3::10]:45762) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Whc6O-00022a-0Z for qemu-devel@nongnu.org; Tue, 06 May 2014 05:56:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Whc6H-0007Qm-R8 for qemu-devel@nongnu.org; Tue, 06 May 2014 05:55:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52180) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Whc6H-0007Qc-JH for qemu-devel@nongnu.org; Tue, 06 May 2014 05:55:49 -0400 From: Markus Armbruster References: <1398764656-27534-1-git-send-email-famz@redhat.com> <1398764656-27534-3-git-send-email-famz@redhat.com> <8761lktrg3.fsf@blackfin.pond.sub.org> <5367ABE0.6040104@redhat.com> <87iopkdt9g.fsf@blackfin.pond.sub.org> <536818AA.50101@redhat.com> Date: Tue, 06 May 2014 11:55:43 +0200 In-Reply-To: <536818AA.50101@redhat.com> (Eric Blake's message of "Mon, 05 May 2014 17:03:06 -0600") Message-ID: <874n131ba8.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH v2 2/2] qapi: Allow setting default values for optional parameters List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake Cc: Kevin Wolf , Peter Maydell , Fam Zheng , qemu-devel@nongnu.org, Michael Roth , Luiz Capitulino , akong@redhat.com Eric Blake writes: > 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). Unlike the other sugared form, this one adds syntax beyond JSON, namely in some (but not all) member names, and that makes it a bit harder to stomach for me. Whether it's worthwhile depends on how common the case "optional, no default" turns out to be. Wait and see. >> 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. :)