From: Simon Marchi <simark@simark.ca>
To: Tom Tromey <tom@tromey.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH] Make BLOCK_START and BLOCK_END into rvalues
Date: Sun, 17 May 2020 10:40:04 -0400 [thread overview]
Message-ID: <2f349f8c-3e39-17cb-9b5c-d2d9c60ee41f@simark.ca> (raw)
In-Reply-To: <87pnb264j2.fsf@tromey.com>
On 2020-05-17 10:05 a.m., Tom Tromey wrote:
> Simon> This is similar to what I'm doing to struct type, so it would be nice to agree
> Simon> on the way forward for all these structures, and change them in a consistent
> Simon> manner.
>
> Makes sense.
>
> Simon> Since you are changing the places that modify the field values, I'd suggest
> Simon> adding the setter right away, it's a step in the right direction.
>
> Simon> And I'd suggest adding the getter too, changing the BLOCK_START macro to use
> Simon> it, it shouldn't be much more work. And it will achieve the goal of making
> Simon> the macro yield an rvalue.
>
> I wasn't sure whether setters and getters would provide any real value.
> Aside from some maybe-future idea of changing the getter, in other
> situations they are just wrappers for the field.
It's true that simply wrapping a field with a getter / setter may not appear valuable.
I think it is somewhat valuable to be able to put a breakpoint on the setter. If you
are wondering where some block with a given start address is created, you can put a
conditional breakpoint on the setter. And to avoid the field being changed behind the
back of that setter, then that field must be private (ideally) and a getter becomes
necessary as well.
I also like getter / setters because they allow adding assertions to make sure things
are in a coherent state.
> For struct type, maybe it makes more sense, because one (very-)
> long-term idea there would be to split up struct main_type into an
> inheritance hierarchy, so that each type can be more obviously
> type-safe, and also carry just the data it needs.
>
> I don't mind making the change -- it's easy enough to do.
As you wish :)
Simon
next prev parent reply other threads:[~2020-05-17 14:40 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-16 15:10 Tom Tromey
2020-05-16 16:15 ` Simon Marchi
2020-05-17 14:05 ` Tom Tromey
2020-05-17 14:40 ` Simon Marchi [this message]
2020-05-16 16:36 ` Christian Biesinger
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=2f349f8c-3e39-17cb-9b5c-d2d9c60ee41f@simark.ca \
--to=simark@simark.ca \
--cc=gdb-patches@sourceware.org \
--cc=tom@tromey.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