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

Reply via email to