From: Markus Armbruster <armbru@redhat.com>
To: Andrea Bolognani <abologna@redhat.com>
Cc: Kevin Wolf <kwolf@redhat.com>, John Snow <jsnow@redhat.com>,
Victor Toso <victortoso@redhat.com>,
qemu-devel@nongnu.org, Eric Blake <eblake@redhat.com>
Subject: Re: [RFC PATCH v1 0/8] qapi: add generator for Golang interface
Date: Mon, 02 May 2022 13:46:23 +0200 [thread overview]
Message-ID: <875ymop374.fsf@pond.sub.org> (raw)
In-Reply-To: <CABJz62MTVhDHZo5+sTJKm5b+SZM_W+_o5VmMgx0NVyibYfs=hw@mail.gmail.com> (Andrea Bolognani's message of "Mon, 2 May 2022 05:04:13 -0400")
Andrea Bolognani <abologna@redhat.com> writes:
> On Mon, May 02, 2022 at 09:21:36AM +0200, Markus Armbruster wrote:
>> Andrea Bolognani <abologna@redhat.com> writes:
>> > The wire protocol would still retain the unappealing name, but at
>> > least client libraries could hide the uglyness from users.
>>
>> At the price of mild inconsistency between the library interface and
>> QMP.
>
> That's fine, and in fact it already happens all the time when QAPI
> names (log-append) are translated to C identifiers (log_append).
There's a difference between trivial translations like "replace '-' by
'_'" and arbitrary replacement like the one for enumeration constants
involving 'prefix'.
>> We could clean up QMP if we care, keeping around the old names for
>> compatibility. See also Kevin's work on QAPI aliases. Which is much
>> more ambitious, though.
>
> I wasn't aware of that effort. Personally I'm always in favor of
> cleaning up inconsistencies, so I am automatically a fan :)
>
> That said, the idea of exposing a sub-par Go API until such massive
> undertaking can be completed is not terribly appealing.
Point.
> And it would
> not address every facet of the issue (see below).
>
>> > Capitalization of these acronyms is inconsistent across the schema,
>>
>> Common issue with camel-cased compounds containing acronyms, because
>> either way is ugly.
>
> Agreed :) But consistent ugliness is still preferable to inconsistent
> ugliness.
True.
>> > with one of the two forms disagreeing with Go naming expectations.
>>
>> Pardon my ignorance: What are Go's expectations?
>
> Acronyms are usually all upper case:
>
> https://pkg.go.dev/net/http#ParseHTTPVersion
> https://pkg.go.dev/net/http#ProxyURL
> https://pkg.go.dev/crypto/tls#NewLRUClientSessionCache
>
> The same seems to be true of Python:
>
> https://docs.python.org/3/library/http.html#http.HTTPStatus
> https://docs.python.org/3/library/urllib.error.html#urllib.error.URLError
> https://docs.python.org/3/library/xmlrpc.server.html#xmlrpc.server.SimpleXMLRPCServer
>
> Rust, on the other hand, seems to prefer only capitalizing the first
> letter of a word, no matter if it's an acronym:
>
> https://doc.rust-lang.org/std/net/struct.TcpStream.html
> https://doc.rust-lang.org/std/net/struct.Ipv4Addr.html
> https://doc.rust-lang.org/std/ffi/struct.OsString.html
Another strange game where the only winning move is not to play.
> Whether different naming conventions are used for types, functions
> and struct members is also language-dependent.
Yes.
>> > In this case we might be able to just change the schema without
>> > introducing backwards compatibility issues, though? Type names are
>> > not actually transmitted on the wire IIUC.
>>
>> Correct!
>
> That's great, but even if we decided to change all type names so that
> the schema is internally consistent and follows a naming convention
> that's reasonable for C, Go and Python, we'd still leave the Rust
> interface looking weird... There's no one-size-fits-all name,
> unfortunately.
C will remain the primary customer for quite a while. It doesn't come
with universally accepted naming conventions, so we made up our own. I
think we have some wiggle room there. We could, for instance, decide to
clean up the current inconsistent capitalization of acronyms in the QAPI
schema to either style, TCPStream or TcpStream.
Your point remains: some names will still look "weird" in some possible
target languages.
>> > Of course such annotations would only be necessary to deal with
>> > identifiers that are not already following the expected naming
>> > conventions and when MLAs are involved.
>>
>> Pardon my ignorance some more: what are MLAs?
>
> Multi Letter Acronyms. Which are actually just called "acronyms" I
> guess? O:-)
Well played!
> The point is that, if we want to provide a language interface that
> feels natural, we need a way to mark parts of a QAPI symbol's name in
> a way that makes it possible for the generator to know they're
> acronyms and treat them in an appropriate, language-specific manner.
It's not just acronyms. Consider IAmALittleTeapot. If you can assume
that only beginning of words are capitalized, even for acronyms, you can
split this into words without trouble. You can't recover correct case,
though: "i am a little teapot" is wrong.
"Split before capital letter" falls apart when you have characters that
cannot be capitalized: Point3d.
Camel case is hopeless.
> The obvious way to implement this would be with an annotation along
> the lines of the one I proposed. Other ideas?
I'm afraid having the schema spell out names in multiple naming
conventions could be onerous. How many names will need it? Times how
many naming conventions?
Another issue: the fancier the translation from schema name to
language-specific name gets, the harder it becomes to find one from the
other.
next prev parent reply other threads:[~2022-05-02 11:47 UTC|newest]
Thread overview: 71+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-01 22:40 [RFC PATCH v1 0/8] qapi: add generator for Golang interface Victor Toso
2022-04-01 22:40 ` [RFC PATCH v1 1/8] qapi: golang: Generate qapi's enum types in Go Victor Toso
2022-05-10 10:06 ` Daniel P. Berrangé
2022-05-10 11:15 ` Victor Toso
2022-05-10 11:19 ` Daniel P. Berrangé
2022-05-10 11:28 ` Victor Toso
2022-05-10 11:39 ` Daniel P. Berrangé
2022-04-01 22:40 ` [RFC PATCH v1 2/8] qapi: golang: Generate qapi's alternate " Victor Toso
2022-05-10 10:10 ` Daniel P. Berrangé
2022-05-10 11:21 ` Victor Toso
2022-05-10 11:28 ` Daniel P. Berrangé
2022-04-01 22:40 ` [RFC PATCH v1 3/8] qapi: golang: Generate qapi's struct " Victor Toso
2022-04-01 22:41 ` [RFC PATCH v1 4/8] qapi: golang: Generate qapi's union " Victor Toso
2022-05-10 10:26 ` Daniel P. Berrangé
2022-05-10 11:32 ` Victor Toso
2022-05-10 11:42 ` Daniel P. Berrangé
2022-04-01 22:41 ` [RFC PATCH v1 5/8] qapi: golang: Generate qapi's event " Victor Toso
2022-05-10 10:42 ` Daniel P. Berrangé
2022-05-10 11:38 ` Victor Toso
2022-04-01 22:41 ` [RFC PATCH v1 6/8] qapi: golang: Generate qapi's command " Victor Toso
2022-04-01 22:41 ` [RFC PATCH v1 7/8] qapi: golang: Add CommandResult type to Go Victor Toso
2022-04-01 22:41 ` [RFC PATCH v1 8/8] qapi: golang: document skip function visit_array_types Victor Toso
2022-04-19 18:12 ` [RFC PATCH v1 0/8] qapi: add generator for Golang interface Andrea Bolognani
2022-04-19 18:42 ` Andrea Bolognani
2022-04-28 13:50 ` Markus Armbruster
2022-04-29 13:15 ` Andrea Bolognani
2022-05-02 7:21 ` Markus Armbruster
2022-05-02 9:04 ` Andrea Bolognani
2022-05-02 11:46 ` Markus Armbruster [this message]
2022-05-02 14:01 ` Andrea Bolognani
2022-05-03 7:57 ` Markus Armbruster
2022-05-03 9:40 ` Andrea Bolognani
2022-05-03 11:04 ` Kevin Wolf
2022-05-10 9:55 ` Daniel P. Berrangé
2022-05-11 6:15 ` Markus Armbruster
2022-05-09 18:53 ` Victor Toso
2022-05-10 8:06 ` Markus Armbruster
2022-05-10 11:48 ` Victor Toso
2022-05-10 9:52 ` Daniel P. Berrangé
2022-05-10 15:25 ` Andrea Bolognani
2022-05-11 13:45 ` Markus Armbruster
2022-05-09 10:21 ` Victor Toso
2022-05-10 17:37 ` Andrea Bolognani
2022-05-10 18:02 ` Daniel P. Berrangé
2022-04-26 11:14 ` Markus Armbruster
2022-05-09 10:52 ` Victor Toso
2022-05-10 8:53 ` Daniel P. Berrangé
2022-05-10 9:06 ` Victor Toso
2022-05-10 9:17 ` Daniel P. Berrangé
2022-05-10 9:32 ` Daniel P. Berrangé
2022-05-10 10:50 ` Victor Toso
2022-05-10 10:57 ` Daniel P. Berrangé
2022-05-10 12:02 ` Markus Armbruster
2022-05-10 12:34 ` Daniel P. Berrangé
2022-05-10 12:51 ` Daniel P. Berrangé
2022-05-11 14:17 ` Markus Armbruster
2022-05-11 14:41 ` Daniel P. Berrangé
2022-05-11 15:38 ` Andrea Bolognani
2022-05-11 15:50 ` Daniel P. Berrangé
2022-05-11 16:22 ` Andrea Bolognani
2022-05-11 16:32 ` Daniel P. Berrangé
2022-05-18 8:10 ` Victor Toso
2022-05-18 8:51 ` Daniel P. Berrangé
2022-05-18 9:01 ` Victor Toso
2022-05-11 14:17 ` Markus Armbruster
2022-05-18 8:55 ` Victor Toso
2022-05-18 12:30 ` Markus Armbruster
2022-05-25 13:49 ` Andrea Bolognani
2022-05-25 14:10 ` Markus Armbruster
2022-06-01 13:53 ` Victor Toso
2022-05-10 10:47 ` Daniel P. Berrangé
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=875ymop374.fsf@pond.sub.org \
--to=armbru@redhat.com \
--cc=abologna@redhat.com \
--cc=eblake@redhat.com \
--cc=jsnow@redhat.com \
--cc=kwolf@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=victortoso@redhat.com \
/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.