All of lore.kernel.org
 help / color / mirror / Atom feed
From: Max Reitz <mreitz@redhat.com>
To: Markus Armbruster <armbru@redhat.com>
Cc: Kevin Wolf <kwolf@redhat.com>,
	qemu-devel@nongnu.org, qemu-block@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v4 2/5] qapi: Add qobject_is_equal()
Date: Mon, 21 Aug 2017 18:12:00 +0200	[thread overview]
Message-ID: <1c873dce-d068-38c7-8aae-635d88ac618d@redhat.com> (raw)
In-Reply-To: <87bmnih60w.fsf@dusky.pond.sub.org>

[-- Attachment #1: Type: text/plain, Size: 3139 bytes --]

On 2017-08-14 11:07, Markus Armbruster wrote:
> Max Reitz <mreitz@redhat.com> writes:
> 
>> On 2017-07-11 13:33, Markus Armbruster wrote:
>>> Max Reitz <mreitz@redhat.com> writes:
>>>
>>>> First of all, OK, you don't want QNum(42.0) to equal QNum(42) at all (at
>>>> least not right now and in the foreseeable future).
>>>> You're the maintainer, so you decide, so I'll go along with it. :-)
>>>>
>>>> Now, let's follow up with my therefore rather useless commentary:
>>>>
>>>> (Feel free to disregard, because honestly, I can see how replying to
>>>> most of the points I'm asking isn't really worth the time...)
>>>
>>> When I use the authority entrusted to maintainers, I feel obliged to at
>>> least explain my reasoning.  Besides, putting my reasoning in words
>>> tends to lead me to new insights.
>>
>> And I am indeed very grateful for that. :-)
>>
>>>> On 2017-07-10 11:17, Markus Armbruster wrote:
>>>>> Max Reitz <mreitz@redhat.com> writes:
>>>>>
>>>>>> On 2017-07-06 16:30, Markus Armbruster wrote:
>>
>> [...]
>>
>>>>> The only way to add unsigned integers without breaking QMP compatibility
>>>>> is to make them interchangeable with signed integers.  That doesn't mean
>>>>> you get to make floating-point numbers interchangeable with integers
>>>>> now.
>>>>
>>>> Again, begs the question why QNum covers floating point numbers then and
>>>> why this very fact is not documented in qnum.c.
>>>
>>> What kind of documentation would you like to see?
>>
>> It would be good to note that the QNum type is not meant to be a
>> completely uniform way to handle JSON numbers (e.g. if the user provides
>> something with a decimal point but you need an integer, QNum will not do
>> that conversion for you).
>>
>> It is (English indirect speech is broken badly) just meant to
>> encapsulate the different variants a number can be represented in, but
>> you're still generally supposed to read it out the way it was put in
>> (exceptions apply, see signed/unsigned and qnum_get_double()).
> 
> Can we distill this into text that could become an actual patch?  Let me
> try.
> 
>     QNum encapsulates how our dialect of JSON fills in the blanks left
>     by the JSON specification (RFC 7159) regarding numbers.
> 
>     Conceptually, we treat number as an abstract type with three
>     concrete subtypes: floating-point, signed integer, unsigned integer.
>     QNum implements this a discriminated union of double, int64_t,
>     uint64_t.
> 
>     The JSON parser picks the subtype as follows.  If the number has a
>     decimal point or an exponent, it is floating-point.  Else if it fits
>     into int64_t, it's signed integer.  Else if it first into uint64_t,
>     it's unsigned integer.  Else it's floating-point.
> 
>     Any number can serve as double: qnum_get_double() converts under the
>     hood.
> 
>     An integer can serve as signed / unsigned integer as long as it is
>     in range: qnum_get_try_int() / qnum_get_try_uint() check range and
>     convert under the hood.
> 
> What do you think?

Sounds very good to me, thanks!

Max


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 512 bytes --]

  reply	other threads:[~2017-08-21 16:19 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-05 19:03 [Qemu-devel] [PATCH v4 0/5] block: Don't compare strings in bdrv_reopen_prepare() Max Reitz
2017-07-05 19:04 ` [Qemu-devel] [PATCH v4 1/5] qapi/qnull: Add own header Max Reitz
2017-07-05 19:04 ` [Qemu-devel] [PATCH v4 2/5] qapi: Add qobject_is_equal() Max Reitz
2017-07-05 19:49   ` Eric Blake
2017-07-09 17:15     ` Max Reitz
2017-07-06 14:30   ` Markus Armbruster
2017-07-09 17:36     ` Max Reitz
2017-07-10  9:17       ` Markus Armbruster
2017-07-10 21:30         ` Max Reitz
2017-07-11 11:33           ` Markus Armbruster
2017-07-11 13:17             ` Max Reitz
2017-08-14  9:07               ` Markus Armbruster
2017-08-21 16:12                 ` Max Reitz [this message]
2017-07-05 19:04 ` [Qemu-devel] [PATCH v4 3/5] block: qobject_is_equal() in bdrv_reopen_prepare() Max Reitz
2017-07-05 19:52   ` Eric Blake
2017-07-05 19:04 ` [Qemu-devel] [PATCH v4 4/5] iotests: Add test for non-string option reopening Max Reitz
2017-07-05 19:04 ` [Qemu-devel] [PATCH v4 5/5] tests: Add check-qobject for equality tests Max Reitz
2017-07-05 20:05   ` Eric Blake
2017-07-09 17:18     ` Max Reitz

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=1c873dce-d068-38c7-8aae-635d88ac618d@redhat.com \
    --to=mreitz@redhat.com \
    --cc=armbru@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=qemu-block@nongnu.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.