From: David Malcolm <dmalcolm@redhat.com>
To: Pedro Alves <pedro@palves.net>, gcc@gcc.gnu.org
Subject: Re: [RFC] Using std::unique_ptr and std::make_unique in our code
Date: Mon, 11 Jul 2022 20:32:07 -0400 [thread overview]
Message-ID: <6e214b5b8c3c50a72ef2340b6d57481c885fe27e.camel@redhat.com> (raw)
In-Reply-To: <6f183e53-02b9-9472-a5cc-9c57c5c0e898@palves.net>
On Mon, 2022-07-11 at 11:56 +0100, Pedro Alves wrote:
> Hi!
>
> On 2022-07-08 9:46 p.m., David Malcolm via Gcc wrote:
> > - pending_diagnostic *d,
> > +
> > std::unique_ptr<pending_diagnostic> d,
>
> I see that you didn't add any typedef for std::unique_ptr<foo> in
> this patch. It will be
> inevitable that people will start adding them, for conciseness, IME,
> though.
Perhaps, but right now I prefer to spell out std::unique_ptr<T>, since
I'm not as comfortable with C++11 as I might be.
> To avoid diverging
> naming styles for such typedefs in the codebase, GDB settled on using
> the "_up" suffix (for Unique Pointer)
> quite early in the C++11 conversion, and we use such typedefs
> pervasively nowadays. For example, for the type
> above, we'd have:
>
> typedef std::unique_ptr<pending_diagnostic> pending_diagnostic_up;
>
> and then:
>
> - pending_diagnostic *d,
> + pending_diagnostic_up d,
>
> I would suggest GCC have a similar guideline, before people start
> using foo_ptr,
> bar_unp, quux_p, whatnot diverging styles.
Thanks for the info. I suspect the gdb community is much more
comfortable with C++ (and C++11) than the gcc community.
The recommendation sounds reasonable for if/when we start adding such
typedefs, but, as I said, for now I think I want to spell out
std::unique_ptr<T> in the few places I'm using it.
Hope this makes sense, and these are just my opinions, of course
Dave
>
> And it would be nice if GCC followed the same nomenclature style as
> GDB, so we could
> have one single guideline for the whole GNU toolchain, so people
> moving between codebases
> only had to learn one guideline.
>
> Pedro Alves
>
next prev parent reply other threads:[~2022-07-12 0:32 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-08 20:46 David Malcolm
2022-07-08 21:15 ` Gabriel Ravier
2022-07-08 21:16 ` Jonathan Wakely
2022-07-11 10:56 ` Pedro Alves
2022-07-12 0:32 ` David Malcolm [this message]
2022-08-10 1:15 ` James K. Lowden
2022-07-12 10:21 ` Florian Weimer
2022-07-12 10:45 ` Jonathan Wakely
2022-07-12 11:01 ` Pedro Alves
2022-07-12 11:00 ` Pedro Alves
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=6e214b5b8c3c50a72ef2340b6d57481c885fe27e.camel@redhat.com \
--to=dmalcolm@redhat.com \
--cc=gcc@gcc.gnu.org \
--cc=pedro@palves.net \
/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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).