From: Eric Blake <eblake@redhat.com>
To: Markus Armbruster <armbru@redhat.com>,
Anton Nefedov <anton.nefedov@virtuozzo.com>
Cc: qemu-devel@nongnu.org, mdroth@linux.vnet.ibm.com
Subject: Re: [Qemu-devel] [PATCH 1/2] qapi: allow flat unions with empty branches
Date: Thu, 17 May 2018 08:21:55 -0500 [thread overview]
Message-ID: <e5230c5b-0675-2611-d10f-51a05f730869@redhat.com> (raw)
In-Reply-To: <87fu2qogew.fsf@dusky.pond.sub.org>
On 05/17/2018 03:05 AM, Markus Armbruster wrote:
>>>>>>> QAPI language design alternatives:
>>>>>>>
>>>>>>> 1. Having unions cover all discriminator values explicitly is useful.
>>>>
>>>>>>> 2. Having unions repeat all the discriminator values explicitly is not
>>>>>>> useful. All we need is replacing the code enforcing that by code
>>>>>>> defaulting missing ones to the empty type.
>>>>>>>
>> I think I'd vote for 2 (never enforce all-branches coverage) as well.
>
> Eric, what do you think?
I'm sold. Let's go ahead and make the change that for any flat union, a
branch not listed defaults to the empty type (no added fields) rather
than being an error, then simplify a couple of the existing flat unions
that benefit from that.
>
> One more thought: if we ever get around to provide more convenient flat
> union syntax so users don't have to enumerate the variant names twice,
> we'll need a way to say "empty branch". Let's worry about that problem
> when we have it.
In other words, our current "simple" unions act in a manner that
declares an implicit enum type - if we ever add an implicit enum to a
flat union (where you don't have to declare a pre-existing enum type),
then you need some syntax to declare additional acceptable enum values
that form an empty branch. Indeed, not a problem to be solved right now.
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization: qemu.org | libvirt.org
next prev parent reply other threads:[~2018-05-17 13:22 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-11 9:05 [Qemu-devel] [PATCH 0/2] qapi: allow flat unions with empty branches Anton Nefedov
2018-05-11 9:05 ` [Qemu-devel] [PATCH 1/2] " Anton Nefedov
2018-05-14 18:08 ` Markus Armbruster
2018-05-14 19:34 ` Eric Blake
2018-05-15 7:01 ` Markus Armbruster
2018-05-15 15:20 ` Eric Blake
2018-05-15 17:40 ` Markus Armbruster
2018-05-16 15:05 ` Anton Nefedov
2018-05-17 8:05 ` Markus Armbruster
2018-05-17 13:21 ` Eric Blake [this message]
2018-05-18 6:45 ` Markus Armbruster
2018-05-18 8:16 ` Anton Nefedov
2018-05-11 9:05 ` [Qemu-devel] [PATCH 2/2] qapi: avoid empty CpuInfoOther type Anton Nefedov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e5230c5b-0675-2611-d10f-51a05f730869@redhat.com \
--to=eblake@redhat.com \
--cc=anton.nefedov@virtuozzo.com \
--cc=armbru@redhat.com \
--cc=mdroth@linux.vnet.ibm.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).