From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41802) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZjNob-0000NC-Pa for qemu-devel@nongnu.org; Tue, 06 Oct 2015 04:41:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZjNoW-0002Rp-P7 for qemu-devel@nongnu.org; Tue, 06 Oct 2015 04:41:41 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60611) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZjNoW-0002Rd-JB for qemu-devel@nongnu.org; Tue, 06 Oct 2015 04:41:36 -0400 From: Markus Armbruster References: <1443760312-656-1-git-send-email-eblake@redhat.com> <1443760312-656-8-git-send-email-eblake@redhat.com> <87bnch76hs.fsf@blackfin.pond.sub.org> <560E9ECE.9050904@redhat.com> <87twq9nqjn.fsf@blackfin.pond.sub.org> <560F28CD.2090807@redhat.com> Date: Tue, 06 Oct 2015 10:41:33 +0200 In-Reply-To: <560F28CD.2090807@redhat.com> (Eric Blake's message of "Fri, 2 Oct 2015 19:01:01 -0600") Message-ID: <87fv1os81u.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH v6 07/12] qapi: Detect collisions in C member names List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake Cc: marcandre.lureau@redhat.com, Michael Roth , ehabkost@redhat.com, qemu-devel@nongnu.org Eric Blake writes: > On 10/02/2015 11:11 AM, Markus Armbruster wrote: > >>>> Why wrap function c_name() in a method? Why not simply call the >>>> function? >>> >>> 'self.c_name()' is shorter than 'c_name(self.name)'. And I already had >>> long lines with that seen[self.c_name()].describe() pattern. >> >> You could also try a local variable: cnam = c_name(self.name). >> >>>> It's method in QAPISchemaEntity only because this lets us add special >>>> cases in a neat way. >>> >>> True, but I _did_ mention in the commit message that I did it for less >>> typing. >>> >>> But as to special cases, yes, I have one in mind (although I have not >>> played with it yet). > >> >> I'm afraid I don't have enough context to grok this late on Friday :) > > Here's another case I have in mind. Right now, we have special code > littered in qapi-types and qapi-visit to track that the > QAPISchemaObjectTypeMember for simple unions is named 'type' in QMP but > 'kind' in C code. Having member.c_name() return 'kind' would simplify > that code. Yes, but naming it 'type' in C will simplify things even more :) Might make sense as an intermediate step all the same. However, if this is the only reason for having a c_name() member, the member will become superfluous when we clean up the type vs. kind stupidity. > So, what I will do for v7 is rework the patches to independently > implement and use member.c_name() (possibly by also creating a special > subclass of QAPISchemaObjectTypeMember), showing how it makes the > clients easier, and then this patch can also make use of that work.