From: Andrew Burgess <aburgess@redhat.com>
To: Simon Marchi <simark@simark.ca>, Tom Tromey <tom@tromey.com>
Cc: gdb-patches@sourceware.org, Guinevere Larsen <guinevere@redhat.com>
Subject: Re: [PATCH] gdbserver: convert program_args to a single string
Date: Wed, 15 Jan 2025 10:21:42 +0000 [thread overview]
Message-ID: <87frlkpebt.fsf@redhat.com> (raw)
In-Reply-To: <ab73dd4f-56c5-449d-b524-334446ea5ad7@simark.ca>
Simon Marchi <simark@simark.ca> writes:
> On 2025-01-14 12:23, Tom Tromey wrote:
>>>>>>> "Simon" == Simon Marchi <simark@simark.ca> writes:
>>
>>>> /* Start a new process.
>>>> PROGRAM is the program name.
>>>> - PROGRAM_ARGS is the vector containing the inferior's args.
>>>> + PROGRAM_ARGS is a string containing all the inferior's arguments.
>>>> Returns the new PID on success, -1 on failure. Registers the new
>>>> process with the process list. */
>>
>> Simon> I think this comment should just be removed, there's no point in
>> Simon> repeating the documentation from the base class.
>>
>> FWIW I normally consider the "override" keyword to be sufficient
>> documentation in these cases; though there's also some code with a
>> comment pointing at the base class.
>
> Speaking of this, I don't really know what to do in these situations, I'd like
> if we could clarify what our style is. Let's say you have:
>
> -- base.h
>
> struct base
> {
> /* 1 */
> virtual void method ();
> };
>
> -- base.c
>
> /* 2 */
>
> void base::method ()
> {
> }
>
> -- impl.c
>
> struct impl : public base
> {
> /* 3 */
> void method () override;
> };
>
> /* 4 */
>
> void impl::method ()
> {
> }
>
> Which comment should you have where? We typically say "all declarations
> and definitions should have a comment", but I feel like it's unnecessary here.
>
> - #1 is where you should have the documentation about the behavior of
> `method`
As Tom said, the actual documentation could be at #1 or #2. With C++
implementing more stuff in headers, having the docs at #1 makes more and
more sense I think.
> - #2 would be the typical /* See base.h. */, although I find these
> comments a bit useless
It is a little useless, but I do like the consistency of all functions
having something. And in some cases, when the declaration is not in the
obvious place, it can help find where to look.
> - As you said, I think the `override` keyword is sufficient to make
> comment #3 unnecessary, unless you want to specify something specific
> to `impl`. I don't see the need to point to the base class, that's
> just implied by how the language works.
Agreed.
> - I never know what to put for #4, you can't put /* See impl.c. */,
> since you're already in impl.c. Again, I feel like a "See whatever"
> comment is a bit useless: if you know C++, you know you need to go
> look at the declaration of struct/class `impl`.
In cases where the base class declaration, and the out-of-line
definitions are in the same file I write /* See class declaration. */
on the definitions (or something similar).
In this example I'd probably go with /* See base.h. */ as that guides
folk to where the comment can be found.
Just thoughts.
Thanks,
Andrew
next prev parent reply other threads:[~2025-01-15 10:22 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-14 13:39 Andrew Burgess
2025-01-14 15:32 ` Simon Marchi
2025-01-14 17:23 ` Tom Tromey
2025-01-14 17:34 ` Simon Marchi
2025-01-14 23:07 ` Tom Tromey
2025-01-15 10:21 ` Andrew Burgess [this message]
2025-01-15 10:09 ` Andrew Burgess
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=87frlkpebt.fsf@redhat.com \
--to=aburgess@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=guinevere@redhat.com \
--cc=simark@simark.ca \
--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