From: Markus Armbruster <armbru@redhat.com>
To: Kevin Wolf <kwolf@redhat.com>
Cc: Peter Krempa <pkrempa@redhat.com>,
qemu-devel@nongnu.org, qemu-block@nongnu.org
Subject: Re: [Qemu-devel] Non-flat command line option argument syntax
Date: Mon, 27 Feb 2017 14:36:40 +0100 [thread overview]
Message-ID: <87innvhi1j.fsf@dusky.pond.sub.org> (raw)
In-Reply-To: <20170227105704.GB6356@noname.redhat.com> (Kevin Wolf's message of "Mon, 27 Feb 2017 11:59:00 +0100")
Kevin Wolf <kwolf@redhat.com> writes:
> Am 27.02.2017 um 11:27 hat Markus Armbruster geschrieben:
>> Markus Armbruster <armbru@redhat.com> writes:
>>
>> [...]
>> > === Dotted keys ===
>> >
>> > One sufficiently powerful syntax extension already exists: the dotted
>> > key convention. It's syntactically unambiguous only when none of the
>> > KEYs involved contains '.' To adopt it across the board, we'd have to
>> > outlaw '.' in KEYs. QAPI outlaws '.' already, but we have a bunch of
>> > QOM properties names with '.'. We'd have to rename at least the ones
>> > that need to be accessible in -object.
>> >
>> > Dotted keys can't express member names that look like integers. We'd
>> > have to outlaw them at least for the objects that are accessible on the
>> > command line. Once again, QAPI outlaws such names already. QOM is
>> > anarchy when it comes to names, however.
>> >
>> > The way dotted keys do arrays is inconsistent with how QOM's automatic
>> > arrayification (commit 3396590) do them: foo.0 vs. foo[0]. Backward
>> > compatibility makes changing the dotted key convention awkward. Perhaps
>> > we can still change QOM.
>>
>> Design flaw: there is no good way to denote an empty array or object
>> other than the root object.
>>
>> Empty KEY=VALUE,... is valid and results in an empty root object.
>>
>> Presence of a KEY that contains periods results in additional non-root
>> objects or arrays. For instance, KEY a.b.c results in root object
>> member "a" that has member "b" that has (scalar) member "c".
>>
>> These additional objects and arrays all have at least one member, by
>> construction.
>>
>> Begs the question how to denote an empty object or array other than the
>> root.
>>
>> A natural idea is to interpret "absent in KEY=VALUE,..." as empty.
>> After all, removing one key from it removes one member when there are
>> more, so why not when there aren't.
>>
>> Sadly, it doesn't work: "absent in KEY=VALUE,..." already means
>> "optional object/array absent", which isn't the same as "empty
>> object/array present".
>>
>> Without additional syntax, all we can do is choose what exactly to make
>> impossible:
>>
>> * Absent key means absent, period. No way to do empty array or object.
>> This is what I implemented.
>
> I'm not currently aware of any places where the difference between a
> present, but empty array and an absent array is actually significant, so
> this is probably the most consistent and useful way to interpret things.
>
> In other words, I agree with your implementation.
>
>> * Absent key means absent, except when the member is visited it means
>> empty. No way to do absent optional array or object.
>>
>> * Likewise, but if the visit is preceeded by a test for presence with
>> visit_optional(), it means absent again. No way to do present
>> optional empty array or object. This requires keeping additional
>> state.
>>
>> Any bright ideas on how to avoid making things impossible?
>
> I can't see any other option than extending the syntax if we need this.
> We can't tell the difference between a string and any other object
> description after =, so we would need to make use of reserved characters
> in the key name.
Think so, too.
> Maybe just 'foo.array[]' (without any =) for an empty
> array or something like that.
Yes, that should do. Likewise foo.object{} for empty object.
{} doesn't even need quoting. [] may.
A trailing period without '=' makes some sense, but looks a bit
error-prone, and can't distinguish between array and object.
> Before we introduce anything like this, do we actually need it?
I don't know whether anything needs optional, present and empty. But
even if the answer is "no" today, it need not remain "no".
Anyone running into a case of "yes", will have to fall back to the JSON
form of -blockdev. Strengthens my belief that providing JSON there is a
good idea.
The insufficient generality of dotted keys bugs me a bit. Not sure
whether it justifies more syntax now. But we should document it.
next prev parent reply other threads:[~2017-02-27 13:36 UTC|newest]
Thread overview: 55+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-02 19:42 [Qemu-devel] Non-flat command line option argument syntax Markus Armbruster
2017-02-02 20:06 ` Eric Blake
2017-02-02 20:23 ` Eric Blake
2017-02-03 7:57 ` Markus Armbruster
2017-02-02 20:27 ` Dr. David Alan Gilbert
2017-02-03 7:50 ` Markus Armbruster
2017-02-03 16:57 ` Dr. David Alan Gilbert
2017-02-04 9:44 ` Markus Armbruster
2017-02-06 10:20 ` Dr. David Alan Gilbert
2017-02-03 20:02 ` [Qemu-devel] [Qemu-block] " Max Reitz
2017-02-04 9:45 ` Markus Armbruster
2017-02-04 10:03 ` [Qemu-devel] " Paolo Bonzini
2017-02-04 11:52 ` Markus Armbruster
2017-02-04 12:43 ` Paolo Bonzini
2017-02-03 10:03 ` Daniel P. Berrange
2017-02-03 11:13 ` Markus Armbruster
2017-02-03 12:37 ` Peter Krempa
2017-02-03 13:53 ` Markus Armbruster
2017-02-03 17:25 ` Richard W.M. Jones
2017-02-04 9:51 ` Markus Armbruster
2017-02-05 20:46 ` [Qemu-devel] [Qemu-block] " Max Reitz
2017-02-03 20:28 ` Max Reitz
2017-02-04 9:56 ` Markus Armbruster
2017-02-04 12:21 ` [Qemu-devel] " Fam Zheng
2017-02-04 12:44 ` Paolo Bonzini
2017-02-04 13:02 ` Fam Zheng
2017-02-04 13:35 ` Markus Armbruster
2017-02-04 14:10 ` Fam Zheng
2017-02-06 6:24 ` Markus Armbruster
2017-02-06 11:08 ` Daniel P. Berrange
2017-02-06 6:57 ` Markus Armbruster
2017-02-06 13:23 ` Kevin Wolf
2017-02-06 15:36 ` Markus Armbruster
2017-02-06 16:33 ` Daniel P. Berrange
2017-02-06 17:24 ` Markus Armbruster
2017-02-06 17:50 ` Daniel P. Berrange
2017-02-06 18:56 ` Markus Armbruster
2017-02-06 17:38 ` Paolo Bonzini
2017-02-06 18:12 ` Markus Armbruster
2017-02-06 21:52 ` Paolo Bonzini
2017-02-07 7:02 ` Markus Armbruster
2017-02-07 9:26 ` Kevin Wolf
2017-02-24 16:04 ` Markus Armbruster
2017-02-24 16:39 ` Daniel P. Berrange
2017-02-24 17:17 ` Eric Blake
2017-02-24 19:15 ` Markus Armbruster
2017-02-27 10:27 ` Markus Armbruster
2017-02-27 10:59 ` Kevin Wolf
2017-02-27 13:36 ` Markus Armbruster [this message]
2017-02-27 19:47 ` Eric Blake
2017-02-28 8:24 ` Markus Armbruster
2017-02-27 19:43 ` Eric Blake
2017-02-28 8:41 ` Markus Armbruster
2017-03-01 9:24 ` Markus Armbruster
2017-03-21 8:40 ` Markus Armbruster
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=87innvhi1j.fsf@dusky.pond.sub.org \
--to=armbru@redhat.com \
--cc=kwolf@redhat.com \
--cc=pkrempa@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.