From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33942) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WO7dx-00059Q-JE for qemu-devel@nongnu.org; Thu, 13 Mar 2014 11:34:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WO7ds-0003uw-SS for qemu-devel@nongnu.org; Thu, 13 Mar 2014 11:34:01 -0400 Received: from lputeaux-656-01-25-125.w80-12.abo.wanadoo.fr ([80.12.84.125]:56133 helo=paradis.irqsave.net) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WO7ds-0003ui-J8 for qemu-devel@nongnu.org; Thu, 13 Mar 2014 11:33:56 -0400 Date: Thu, 13 Mar 2014 16:33:55 +0100 From: =?iso-8859-1?Q?Beno=EEt?= Canet Message-ID: <20140313153355.GA5294@irqsave.net> References: <20140228155309.28087.96600.stgit@fimbulvetr.bsc.es> <20140228155321.28087.44860.stgit@fimbulvetr.bsc.es> <87eh2mgusw.fsf@blackfin.pond.sub.org> <87d2i3z7l0.fsf@fimbulvetr.bsc.es> <8738izxpyb.fsf@blackfin.pond.sub.org> <5314C244.5070805@redhat.com> <87y50qs85q.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <87y50qs85q.fsf@blackfin.pond.sub.org> Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v4 2/3] qapi: Add a primitive to include other files from a QAPI schema file List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster Cc: qemu-devel@nongnu.org The Tuesday 04 Mar 2014 =E0 09:02:57 (+0100), Markus Armbruster wrote : > Eric Blake writes: >=20 > > On 03/03/2014 08:27 AM, Markus Armbruster wrote: > > > >>>>> +The QAPI schema definitions can be modularized using the 'includ= e' > >>>>> directive: > >>>>> + > >>>>> + include("sub-system/qapi.json") > >>> > >>>> And now it isn't JSON anymore. > >>> > >>>> To keep it JSON, use syntax like > >>> > >>>> { "include": "sub-system/qapi.json" } > > > > I actually think this looks nicer - makes the file more consistent. >=20 > I suspect qapi.py would look nicer, too :) >=20 > >>>> If you absolutely must make it non-JSON, you better rename the .js= on > >>>> files. > >>> > >>>> Hmm, we already are non-JSON, because we use ' instead of " for no= sane > >>>> reason. > > > > A weak argument: ' is easier than " to type (at least on US keyboards= - > > no shift key required). > > > > Another weak argument: using ' in the qapi files vs. " in actual QMP > > makes it easy to interleave discussions about semantics vs. examples = of > > those semantics in use (you can see whether a code snippet is talking > > about qapi or wire format based on what quoting it used) > > > > Our files are already non-JSON due to comments (JSON has no notion of= # > > introducing a comment to ignore text to the next newline). But both = our > > use of comments and our use of ' instead of " can be remedied in a > > one-pass sed script to get a true JSON output if such is needed, at > > least as long as we don't need to quote any " characters in the schem= a. > > > > Therefore, I agree that making the include syntax closer to true JSON= is > > desirable, whether or not we also decide to use " in the files to beg= in > > with. I don't see any way around the fact that JSON doesn't define > > comments, vs. our absolute need for comments in our schema files, tho= ugh. >=20 > We certainly can't do without comments. >=20 > JSON is designed for easy data exchange, but we use it as programming > language syntax. Its restrictions make sense for easy data exchange, > but hurt our use. We're not the first ones experiencing that pain: > http://json5.org/ >=20 > No idea how much momentum this JSON5 thingy has... >=20 > >>>> Our JSON parser accepts ' as an extension, to save us quoting in C > >>>> strings. That reason doesn't apply to .json files. > >>> > >>> Is it a problem if they are not pure JSON? In the end, they are par= sed by > >>> qapi.py (which already knows about file syntax), and having a separ= ate syntax > >>> for includes makes it somewhat easier to spot when that happens. > >>=20 > >> I don't particularly care whether schema syntax is pure JSON, some > >> bastardized variation of JSON, or something else entirely. But as l= ong > >> as we advertize schema files it as .json, they better contain JSON. = If > >> they contain something else, they should be called something else. > > > > Maybe .qapi? But the name qapi-schema.qapi sounds redundant... >=20 > schema.qapi? >=20 > Switch to JSON5 and call it qapi-schema.json5? >=20 Hmm don't we want something that python and other language know how to pa= rse out of the box ? Or will we write yet another delicate work of art to parse i= t ? Best regards Beno=EEt