From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60454) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WhKfZ-0003sT-UJ for qemu-devel@nongnu.org; Mon, 05 May 2014 11:19:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WhKfU-0002E8-PN for qemu-devel@nongnu.org; Mon, 05 May 2014 11:19:05 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53912) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WhKfU-0002E4-Hw for qemu-devel@nongnu.org; Mon, 05 May 2014 11:19:00 -0400 Message-ID: <5367ABE0.6040104@redhat.com> Date: Mon, 05 May 2014 09:18:56 -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> In-Reply-To: <8761lktrg3.fsf@blackfin.pond.sub.org> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="3Jl4OJLucuigK0BNhAVhRwt6hE3COafEV" 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 , Fam Zheng Cc: Kevin Wolf , Peter Maydell , qemu-devel@nongnu.org, Michael Roth , Luiz Capitulino , akong@redhat.com This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --3Jl4OJLucuigK0BNhAVhRwt6hE3COafEV Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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 } } >> >=20 > Can we keep a parameter's properties together? Perhaps like this: >=20 > NAME: { 'type': TYPE, 'default': DEFAULT } >=20 > where >=20 > NAME: { 'type': TYPE } >=20 > can be abbreviated to >=20 > 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'.= >=20 > and >=20 > NAME: { 'type': TYPE, 'default': null } > to >=20 > NAME-PREFIXED-BY_ASKTERISK: TYPE >=20 > 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. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --3Jl4OJLucuigK0BNhAVhRwt6hE3COafEV 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/ iQEcBAEBCAAGBQJTZ6vgAAoJEKeha0olJ0NqDawH/1dsfrhLQQIEm7lVGKrW9YzY LESsr4VYHP/2ueZrm+r8iGoN1Pe7evrJ2Z0Inyv3o4ulyMxFlsoJ+bK5xyEO+lXS RH/ZwaWPQ4mmy5+DuhNrQ7Z1bV0lGdTVYgiuOGUQNL2e7YtQSUXmpCQhLzyCKDPU JjkJZLJLEe7bsFgtFRgDsBxOElDnEe1IlsCWbQYVdJOHPi7N/XyDbAD+BsBgW3/6 gxArzMBYz4ucN9OE1L97PFA+dpkd4mv4S4Y3FJRSrlKRnWtHXtiPIdS3AL34Xkso PPpB1Zc8r5hu17eVvxpPQV8wYd0qfteG3rJW3jkfGfMlbr6C/545TuVafT0KECE= =zWw5 -----END PGP SIGNATURE----- --3Jl4OJLucuigK0BNhAVhRwt6hE3COafEV--