From: Markus Armbruster <armbru@redhat.com>
To: Eric Blake <eblake@redhat.com>
Cc: qemu-devel@nongnu.org, Michael Roth <mdroth@linux.vnet.ibm.com>
Subject: Re: [Qemu-devel] [PATCH v8 13/18] qapi: Track owner of each object member
Date: Tue, 13 Oct 2015 18:30:12 +0200 [thread overview]
Message-ID: <87oag220kr.fsf@blackfin.pond.sub.org> (raw)
In-Reply-To: <561D1767.8040100@redhat.com> (Eric Blake's message of "Tue, 13 Oct 2015 08:38:31 -0600")
Eric Blake <eblake@redhat.com> writes:
> On 10/13/2015 07:14 AM, Markus Armbruster wrote:
>> Eric Blake <eblake@redhat.com> writes:
>>
>>> Future commits will migrate semantic checking away from parsing
>>> and over to the various QAPISchema*.check() methods. But to
>>> report an error message about an incorrect semantic use of a
>>> member of an object type, it helps to know which type, command,
>>> or event owns the member. In particular, when a member is
>>> inherited from a base type, it is desirable to associate the
>>> member name with the base type (and not the type calling
>>> member.check()).
>>>
>
>>>
>>> + def describe(self):
>>> + owner = self.owner
>>> + # See QAPISchema._make_implicit_object_type() - reverse the
>>> + # mapping there to create a nice human-readable description
>>> + if owner.startswith(':obj-'):
>>> + owner = owner[5:]
>>> + if owner.endswith('-arg'):
>>> + source = '(argument of %s)' % owner[:4]
>>> + elif owner.endswith('-data'):
>>> + source = '(data of %s)' % owner[:5]
>>> + else:
>>> + assert owner.endswith('-wrapper')
>>> + source = '(branch of %s)' % owner[:8]
>>> + else:
>>> + source = '(%s of %s)' % (self.role, owner)
>>> + return "'%s' %s" % (self.name, source)
>>
>> Perhaps not exactly pretty, but it gets the job done with minimal fuss.
>> Sold.
>
> Ouch - I think these should be owner[:-4] (and similar) - I want the
> slice that excludes the last four bytes, and not one that is four bytes
> long. (It happened to work in my tests because I was testing on
> :obj-oops-arg, where owner[:4] and owner[:-4] gave the same 'oops' string).
>
> It's an easy fixup to squash in, so I'm not yet sure if I need a full v9
> respin.
If we decide we can do without a respin, I'll want the incremental patch
to squash in.
>>> +
>>> + role = 'member'
>>> +
>>>
>>
>> Class variables are usually defined first, before methods.
>
> Sure, can do. pep8 didn't complain, and I didn't check if pylint warns
> about it.
PEP8 (the document) doesn't ask for it, but the examples I found in the
Python tutorial are consistently putting them first.
>>> # TODO Drop this class once we no longer have the 'type'/'kind' mismatch
>>> class QAPISchemaObjectTypeUnionTag(QAPISchemaObjectTypeMember):
>>> @@ -1034,6 +1061,11 @@ class QAPISchemaObjectTypeUnionTag(QAPISchemaObjectTypeMember):
>>> assert self.type.is_implicit()
>>> return 'kind'
>>>
>>> + def describe(self):
>>> + # Must override superclass describe() because self.name is 'type'
>>
>> I don't find this argument convincing. I think 'kind' is exactly as
>> unhelpful as 'type' is. Specifically, should we report a QMP clash,
>> calling it 'kind' is confusing (it actually clashes with 'type').
>> Conversely 'type' is confusing when we report a C clash.
>>
>> The helpful part...
>>
>>> + assert self.owner[0] != ':'
>>> + return "'kind' (implicit tag of %s)" % self.owner
>>> +
>>
>> ... is (implicit tag of FOO).
>>
>> Fortunately, you're working towards killing the kind vs. type confusion.
>> Suggest to either rephrase the comment, or simply drop it.
>
> Drop the comment is fine by me.
>
> I personally thought the message needed to report 'kind', because 16/18
> ends up reporting:
>
> +tests/qapi-schema/union-clash-type.json:8: 'kind' (branch of TestUnion)
> collides with 'kind' (implicit tag of TestUnion)
>
> If I didn't override describe() at all, it would report:
>
> ...: 'kind' (branch of TestUnion) collides with 'type' (member of TestUnion)
>
> If all I did was override 'role = "implicit tag"' instead of describe(),
> it would report:
>
> ...: 'kind' (branch of TestUnion) collides with 'type' (implicit tag of
> TestUnion)
Good enough for me considering we'll clean up the 'kind' vs. 'type' mess
soon.
> Of course when a later subset fixes the kind/type misnomer, the error
> message changes:
>
> ...: 'type' (branch of TestUnion) collides with 'type' (member of TestUnion)
>
> where we lose the "implicit tag" because we completely lose the subclass.
Still good enough for me.
We could perhaps leverage is_implicit() to make it (implicit member of
TestUnion).
> Any preferences on which error message to prefer, and therefore how much
> (or how little) we need to override in this temporary subclass? Or is
> this an argument for making the subclass permanent (with a 'role =
> "implicit tag"') even after the kind/type rename?
I think I'd prefer the simplest solution that still gives understandable
error messages.
I'd even accept temporary regressions in error message quality if it
simplifies coding or review, or reduces churn.
When a little effort can yield significantly better error messages in
the final state, feel free to go for it, of course.
next prev parent reply other threads:[~2015-10-13 16:30 UTC|newest]
Thread overview: 51+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-13 4:22 [Qemu-devel] [PATCH v8 00/18] post-introspection cleanups, subset B Eric Blake
2015-10-13 4:22 ` [Qemu-devel] [PATCH v8 01/18] qapi: Use predicate callback to determine visit filtering Eric Blake
2015-10-13 4:22 ` [Qemu-devel] [PATCH v8 02/18] qapi: Prepare for errors during check() Eric Blake
2015-10-13 4:22 ` [Qemu-devel] [PATCH v8 03/18] qapi: Drop redundant alternate-good test Eric Blake
2015-10-13 4:22 ` [Qemu-devel] [PATCH v8 04/18] qapi: Move empty-enum to compile-time test Eric Blake
2015-10-13 4:22 ` [Qemu-devel] [PATCH v8 05/18] qapi: Drop redundant returns-int test Eric Blake
2015-10-13 4:22 ` [Qemu-devel] [PATCH v8 06/18] qapi: Drop redundant flat-union-reverse-define test Eric Blake
2015-10-13 4:22 ` [Qemu-devel] [PATCH v8 07/18] qapi: Don't use info as witness of implicit object type Eric Blake
2015-10-13 11:40 ` Markus Armbruster
2015-10-13 13:05 ` Eric Blake
2015-10-13 4:22 ` [Qemu-devel] [PATCH v8 08/18] qapi: Lazy creation of array types Eric Blake
2015-10-14 7:15 ` Markus Armbruster
2015-10-14 12:57 ` Eric Blake
2015-10-13 4:22 ` [Qemu-devel] [PATCH v8 09/18] qapi: Create simple union type member earlier Eric Blake
2015-10-13 4:22 ` [Qemu-devel] [PATCH v8 10/18] qapi: Move union tag quirks into subclass Eric Blake
2015-10-13 12:10 ` Markus Armbruster
2015-10-13 14:15 ` Eric Blake
2015-10-13 16:56 ` Markus Armbruster
2015-10-13 4:22 ` [Qemu-devel] [PATCH v8 11/18] qapi: Simplify gen_struct_field() Eric Blake
2015-10-13 12:12 ` Markus Armbruster
2015-10-13 13:11 ` Eric Blake
2015-10-13 4:22 ` [Qemu-devel] [PATCH v8 12/18] qapi: Track location that created an implicit type Eric Blake
2015-10-13 12:19 ` Markus Armbruster
2015-10-13 14:27 ` Eric Blake
2015-10-13 4:22 ` [Qemu-devel] [PATCH v8 13/18] qapi: Track owner of each object member Eric Blake
2015-10-13 13:14 ` Markus Armbruster
2015-10-13 14:38 ` Eric Blake
2015-10-13 16:30 ` Markus Armbruster [this message]
2015-10-13 4:22 ` [Qemu-devel] [PATCH v8 14/18] qapi: Detect collisions in C member names Eric Blake
2015-10-13 4:22 ` [Qemu-devel] [PATCH v8 15/18] qapi: Move duplicate member checks to schema check() Eric Blake
2015-10-13 15:06 ` Markus Armbruster
2015-10-13 15:35 ` Eric Blake
2015-10-13 17:13 ` Markus Armbruster
2015-10-13 17:43 ` Eric Blake
2015-10-13 18:32 ` Markus Armbruster
2015-10-13 20:17 ` Eric Blake
2015-10-13 20:20 ` Eric Blake
2015-10-14 7:11 ` Markus Armbruster
2015-10-14 7:32 ` Markus Armbruster
2015-10-14 12:59 ` Eric Blake
2015-10-14 13:23 ` Markus Armbruster
2015-10-13 4:22 ` [Qemu-devel] [PATCH v8 16/18] qapi: Move duplicate enum value " Eric Blake
2015-10-13 18:35 ` Markus Armbruster
2015-10-13 19:37 ` Eric Blake
2015-10-13 4:22 ` [Qemu-devel] [PATCH v8 17/18] qapi: Add test for alternate branch 'kind' clash Eric Blake
2015-10-13 18:43 ` Markus Armbruster
2015-10-13 19:42 ` Eric Blake
2015-10-13 4:22 ` [Qemu-devel] [PATCH v8 18/18] qapi: Detect base class loops Eric Blake
2015-10-13 18:26 ` [Qemu-devel] [PATCH v8 06.5/18] qapi: Drop redundant args-member-array test Eric Blake
2015-10-13 18:51 ` Markus Armbruster
2015-10-13 18:46 ` [Qemu-devel] [PATCH v8 00/18] post-introspection cleanups, subset B 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=87oag220kr.fsf@blackfin.pond.sub.org \
--to=armbru@redhat.com \
--cc=eblake@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 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.