From: Simon Marchi <simon.marchi@polymtl.ca>
To: Pedro Alves <palves@redhat.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH 1/2] Fix sorting of enum values in FlagEnumerationPrinter
Date: Tue, 19 Jan 2016 16:41:00 -0000 [thread overview]
Message-ID: <35bba9e534e14532c11ad7c0a5c1db2b@simark.ca> (raw)
In-Reply-To: <569E17C5.6080909@redhat.com>
On 2016-01-19 06:02, Pedro Alves wrote:
> Thanks for catching this.
>
> I find it surprising that the printer doesn't respect the
> order of the values as they're defined though. Shouldn't we
> remove the sort line entirely, thus keeping the
> existing behavior? I couldn't find mention of the sorting
> in the documentation either.
>
> Or, maybe the printer doesn't work correctly if the "overlapping"
> value (which I think it the whole point of this printer) is defined
> before the particular values, like, e.g.:
>
> enum flag_enum
> {
> ALL = 1 | 2 | 4,
> FLAG_2 = 2,
> FLAG_3 = 4,
> FLAG_1 = 1,
> };
>
> ?
If we don't sort the values and ALL is defined first, then 0x7 will be
displayed as ALL instead of FLAG_1 | FLAG_2 | FLAG_3. I don't think
either is wrong, we just don't know which one each particular user
would prefer. So I think we can choose one way (sorted order, or
definition order) and stick with it.
Personally, I think I would prefer the more explicit version
(FLAG_1 | FLAG_2 | FLAG_3), which means keeping the sort.
> On 01/19/2016 04:23 AM, Simon Marchi wrote:
>
>> +
>> enum flag_enum
>> {
>> - FLAG_1 = 1,
>> + /* Define the enumration values in an unsorted manner to verify
>> that we
>> + effectively sort them by value. */
>
> typo: "enumration".
Fixed.
next prev parent reply other threads:[~2016-01-19 16:41 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-19 4:23 Simon Marchi
2016-01-19 4:23 ` [PATCH 2/2] Fix enum flag with Python 3 Simon Marchi
2016-01-19 11:03 ` Pedro Alves
2016-01-19 16:08 ` Simon Marchi
2016-01-19 11:02 ` [PATCH 1/2] Fix sorting of enum values in FlagEnumerationPrinter Pedro Alves
2016-01-19 16:41 ` Simon Marchi [this message]
2016-01-20 14:41 ` Pedro Alves
2016-01-20 18:03 ` Simon Marchi
2016-01-20 18:12 ` Simon Marchi
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=35bba9e534e14532c11ad7c0a5c1db2b@simark.ca \
--to=simon.marchi@polymtl.ca \
--cc=gdb-patches@sourceware.org \
--cc=palves@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox