qemu-block
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v4 03/14] qapi: Introduce default values for str


From: Eric Blake
Subject: Re: [Qemu-devel] [PATCH v4 03/14] qapi: Introduce default values for struct members
Date: Thu, 21 Nov 2019 09:24:44 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.1.1

On 11/21/19 9:07 AM, Markus Armbruster wrote:
Max Reitz <address@hidden> writes:

With this change, it is possible to give default values for struct
members, as follows:

   What you had to do so far:

     # @member: Some description, defaults to 42.
     { 'struct': 'Foo',
       'data': { '*member': 'int' } }

   What you can do now:

     { 'struct': 'Foo',
       'data': { '*member': { 'type': 'int', 'default': 42 } }

The '*' is redundant in this form.

Can anyone think of reasons for keeping it anyway?  Against?

Is there ever a reason to allow an optional member but without a 'default' value? Or can we just blindly state that if 'default' is not present, that is the same as 'default':0/'default':null?

Or, applying your statement further,

'data': { '*a':'int', '*b':'str' }

is shorthand for:

'data': { 'a': { 'type':'int', 'default':0 },
          'b': { 'type':'str', 'default':null } }

So I could live with permitting '*' only in the shorthand form, and declaring that it is incompatible with longhand form because the existence of a 'default' key in longhand form is evidence that the member is therefore optional.

--
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org




reply via email to

[Prev in Thread] Current Thread [Next in Thread]