From: "Daniel P. Berrangé" <berrange@redhat.com>
To: Markus Armbruster <armbru@redhat.com>
Cc: Victor Toso <victortoso@redhat.com>,
qemu-devel@nongnu.org, John Snow <jsnow@redhat.com>,
Andrea Bolognani <abologna@redhat.com>
Subject: Re: [PATCH v3 1/8] qapi: golang: Generate enum type
Date: Tue, 14 Jan 2025 10:36:48 +0000 [thread overview]
Message-ID: <Z4Y-QG5qWMRI7alY@redhat.com> (raw)
In-Reply-To: <878qrdkcag.fsf@pond.sub.org>
On Tue, Jan 14, 2025 at 09:52:23AM +0100, Markus Armbruster wrote:
> Victor Toso <victortoso@redhat.com> writes:
>
> > This patch handles QAPI enum types and generates its equivalent in Go.
> > We sort the output based on enum's type name.
>
> Any particular reason for sorting?
>
> The existing backends generate output it source order, on the (bold?)
> assumption that developers care to pick an order that makes sense.
Even if that assumption is valid (and I question whether it really is),
what makes sense to a QEMU maintainer is not the same as what makes
sense to a consumer of QEMU.
Our approach to file splitting is fairly arbitrary
First, we've got a split across sub-systems, except where we don't.
Sometimes one subsystem splits into many files. eg block.json vs
block-core.json vs block-export.json
Sometimes we just pull something into a standalone file even when it
is not really a subsystem just common code. eg sockets.json
Sometimes we have a split because its convenient for QEMU linux-user
vs system compilation & ELF linker needs. eg misc.json vs misc-target.json
At best we can say that the split of files is intentionally done for the
convenience of the QEMU maintainers. This is irrevelant (and harmful)
for anyone who isn't a QEMU maintainer, which covers any consumer of the
Go code.
IMHO it is also a bug that this file split leaks out into our existing
QAPI docs.
Then when adding to files, sometimes people append to the end of a
file, sometimes it is injected in the middle. I can't say that is an
intentional/concious ordering decision.
The overall result is that wearing my hat of a consumer of QEMU, when
looking at the QAPI schema there is no discernable ordering.
Given the source ordering is not useful, there are two choices
* Sort to have declarations before use as primary key, and then
alphabetical as a secondary sort key
* Sort alphabetically as the primary key
Fortunately the Go compiler has no requirement for forward declarations.
Sorting declarations before use also doesn't really have much effect on
most declarations, so the first option ends up 90% alphabetical sorted
anyway. Might as well just go the whole way and do pure alphabetical
sorting.
Comparing the enums code in "source order":
https://gitlab.com/victortoso/qapi-go/-/blob/qapi-golang-v1-by-tags/pkg/qapi/enums.go
vs alphabetical order:
https://gitlab.com/victortoso/qapi-go/-/blob/qapi-golang-v3-by-tags/pkg/qapi/enums.go
the improvement is massive IMHO.
With regards,
Daniel
--
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o- https://fstop138.berrange.com :|
|: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
next prev parent reply other threads:[~2025-01-14 10:37 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-10 10:49 [PATCH v3 0/8] qapi-go: add generator for Golang interfaces Victor Toso
2025-01-10 10:49 ` [PATCH v3 1/8] qapi: golang: Generate enum type Victor Toso
2025-01-14 8:52 ` Markus Armbruster
2025-01-14 9:38 ` Victor Toso
2025-01-14 10:36 ` Daniel P. Berrangé [this message]
2025-01-17 10:10 ` Daniel P. Berrangé
2025-01-17 10:22 ` Victor Toso
2025-01-10 10:49 ` [PATCH v3 2/8] qapi: golang: Generate alternate types Victor Toso
2025-01-10 10:49 ` [PATCH v3 3/8] qapi: golang: Generate struct types Victor Toso
2025-01-10 10:49 ` [PATCH v3 4/8] qapi: golang: structs: Address nullable members Victor Toso
2025-01-10 10:49 ` [PATCH v3 5/8] qapi: golang: Generate union type Victor Toso
2025-01-10 10:49 ` [PATCH v3 6/8] qapi: golang: Generate event type Victor Toso
2025-01-10 10:49 ` [PATCH v3 7/8] qapi: golang: Generate command type Victor Toso
2025-01-10 10:49 ` [PATCH v3 8/8] docs: add notes on Golang code generator Victor Toso
2025-01-13 12:52 ` [PATCH v3 0/8] qapi-go: add generator for Golang interfaces Markus Armbruster
2025-01-14 9:44 ` Victor Toso
2025-01-17 10:32 ` Daniel P. Berrangé
2025-01-16 21:59 ` Daniel P. Berrangé
2025-01-17 10:44 ` Markus Armbruster
2025-01-29 19:53 ` Victor Toso
2025-02-11 10:25 ` Victor Toso
2025-02-11 11:10 ` Daniel P. Berrangé
2025-02-11 12:08 ` Victor Toso
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=Z4Y-QG5qWMRI7alY@redhat.com \
--to=berrange@redhat.com \
--cc=abologna@redhat.com \
--cc=armbru@redhat.com \
--cc=jsnow@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.