From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33584) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WhRum-0003Nx-MN for qemu-devel@nongnu.org; Mon, 05 May 2014 19:03:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WhRuh-0002zv-NR for qemu-devel@nongnu.org; Mon, 05 May 2014 19:03:16 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56612) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WhRuh-0002zg-Ea for qemu-devel@nongnu.org; Mon, 05 May 2014 19:03:11 -0400 Message-ID: <536818AA.50101@redhat.com> Date: Mon, 05 May 2014 17:03:06 -0600 From: Eric Blake MIME-Version: 1.0 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> In-Reply-To: <87iopkdt9g.fsf@blackfin.pond.sub.org> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="ARpRIAwebLXRVp3hpj2XTAqcB98tHKHDk" 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: Markus Armbruster Cc: Kevin Wolf , Peter Maydell , Fam Zheng , Michael Roth , qemu-devel@nongnu.org, Luiz Capitulino , akong@redhat.com This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --ARpRIAwebLXRVp3hpj2XTAqcB98tHKHDk Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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, an= d >> 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 in= to >> 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. >=20 > Glad you mention introspection; I didn't think of it. >=20 > The "an asterisk at the beginning of a name is not part of the name, bu= t > means the parameter is optional" thing is a deviation from our usual > design rule against parsing strings in addition to JSON. My proposal t= o > make the "is optional" property an ordinary JSON member straightens thi= s > out. >=20 > 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). >=20 > 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.= >=20 > 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. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --ARpRIAwebLXRVp3hpj2XTAqcB98tHKHDk Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJTaBiqAAoJEKeha0olJ0Nq0wAH/RhOiGAFXtyHn37hAhN27SAX QJ4uT5X082SfRu7tc5f0wSd9Bal2wu1VtWvuobWvuKF3f8OUqQfvg9Oysh9zoOm4 LPgECh12wH2/z34+a87+Xb1k0rHK4wGAbR6r1agZ2R+7wChQ7jQyaxZVQ+TrQaiL r63Hs81vOuOwUkPBsqj/PUdjgv5/3GKCWZfxJvl2ri1ue74eSbCZLqweC7ekIStH kTxNHssktUF78sO8fvsq03LJmre3bUuPU1RnivxduMslxZE8cXABa9y8Y27P8PaE 2yIUnQN1PhcFY+SroLEZlVAtWxlQyWeeNcLA495+kw2TKHAzO9f+OIEzkGzre4Q= =hdgT -----END PGP SIGNATURE----- --ARpRIAwebLXRVp3hpj2XTAqcB98tHKHDk--