From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38938) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YdHan-0002v9-To for qemu-devel@nongnu.org; Wed, 01 Apr 2015 08:17:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YdHaj-0004jN-DQ for qemu-devel@nongnu.org; Wed, 01 Apr 2015 08:17:57 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35614) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YdHaj-0004j5-5C for qemu-devel@nongnu.org; Wed, 01 Apr 2015 08:17:53 -0400 Message-ID: <551BE1ED.3010707@redhat.com> Date: Wed, 01 Apr 2015 06:17:49 -0600 From: Eric Blake MIME-Version: 1.0 References: <1427227433-5030-1-git-send-email-eblake@redhat.com> <1427227433-5030-18-git-send-email-eblake@redhat.com> <20150331152359.GC4748@noname.redhat.com> <87sicl2akl.fsf@blackfin.pond.sub.org> <20150401083150.GB3593@noname.str.redhat.com> <87vbhgur9x.fsf@blackfin.pond.sub.org> In-Reply-To: <87vbhgur9x.fsf@blackfin.pond.sub.org> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="uXWaHpiT3RIH3Clhvs8CeXisODr7b8Xqo" Subject: Re: [Qemu-devel] [PATCH v5 17/28] qapi: Allow true, false and null in schema json List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster , Kevin Wolf Cc: lcapitulino@redhat.com, famz@redhat.com, qemu-devel@nongnu.org, wenchaoqemu@gmail.com This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --uXWaHpiT3RIH3Clhvs8CeXisODr7b8Xqo Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 04/01/2015 03:33 AM, Markus Armbruster wrote: >>> Longhand: >>> >>> # mandatory >>> 'name': { 'type': 'str' } >>> # optional, with a default >>> 'flag': { 'type': 'bool', 'default': true } >>> # optional, no default >>> 'string': { 'type': 'str', 'default': null } >>> >>> Presence of 'default' implies optional. >>> >>> Equivalent shorthand, if any: >>> >>> 'name': 'str' >>> '*string': 'str' >> >> A nice shorthand for defaults would be: >> >> '*name': 'str' =3D 'default' >> >> Though that would be neither valid JSON nor Python any more. Do we >> actually rely on this property anywhere or is it only parsed by the QA= PI >> generator anyway and we can extend the language in such ways? >=20 > I guess JSON / Python was chosen as QAPI schema language to save us the= > bother of defining a syntax and building the tools to work with it, lik= e > an Emacs mode. JSON's not exactly my favourite choice, but at least > it's not XML. >=20 > What we have now isn't JSON, but it's still a subset of Python, and the= > Python tools work. If we go beyond Python, they'll break. Well, we were a subset of Python, until this patch added true, false, and null (the Python way would have been True, False, and None). We are also similar to JSON5, http://json5.org/ Among other things, JSON5 allows trailing commas, allows unquoted keys in a dictionary, allows single-quoted strings, and allows C-style comment= s. >=20 > If we decide to sacrifice these tools for readability, then we can just= > as well replace the syntax entirely. Preferably by something where I > don't have to put every identifier in quotes. >=20 > In short, you're welcome to hack up qapi.py some more for schema > readability, but either keep Emacs Python mode working, or provide a > replacement :) Since we're not quite python or JSON, we've already rolled our own parser; so rewriting QAPI to use a syntax of our own choosing is not that much of a leap. But not for this series. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --uXWaHpiT3RIH3Clhvs8CeXisODr7b8Xqo 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/ iQEcBAEBCAAGBQJVG+HtAAoJEKeha0olJ0Nqnd8H/jHykTTHYd13Ad1ei8CmMvo+ jdFj1YT7gygZRhleDbL2/QgzromwoCPWKWYlYIYTfUs6U2+z9n4gtQ04COxm56p8 SEXQlB7PYbE7IXRjpryD35hVKe4XjrivnXp+mv2cJP449lzFge3XfYzrARi9ZsEl Sbw+uvxR7Q0HhdGoVYGrOBwua/YIaVV0BxzKNYpy6jzvmO4IlPMlhpFDB4mHrWmF CKxkaY9cqFkOcuzGtCZKBonX0zd4mD+OqImUxzTrlQR15Z+kCI5p2W0AuMCAM91J kxGKJgvvddoDewpAQnAfPwMn2f/O469s+K39qhUbVHBfK5MY9Kx+sxVybmZP7zc= =ME+b -----END PGP SIGNATURE----- --uXWaHpiT3RIH3Clhvs8CeXisODr7b8Xqo--