public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Paul Koning <paulkoning@comcast.net>
To: Simon Marchi <simon.marchi@polymtl.ca>
Cc: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Subject: Re: Coding standards proposal, usage of "this"
Date: Fri, 13 Aug 2021 10:46:21 -0400	[thread overview]
Message-ID: <01BE4175-EDDE-4B84-9FE8-B0C748BE0808@comcast.net> (raw)
In-Reply-To: <c99dc37f-a968-3374-94ff-3536b7f220ef@polymtl.ca>



> On Aug 13, 2021, at 10:26 AM, Simon Marchi via Gdb-patches <gdb-patches@sourceware.org> wrote:
> 
> Hi all,
> 
> Here's something I had in mind for a while.  We don't consistently use
> `this` when referring to fields or methods of the current object.  I
> never now if I should use it or not, or point it out in review.  I
> therefore propose these rules so that we have something to refer to.
> 
> - Use `this` when referring to a data member that is not prefixed by
>   `m_`.  Rationale: without `this`, it's not clear that you are
>   referring to a member of the current class, versus a local or global
>   variable.
> - Don't use `this` when referring to a data member that is prefixed by
>   `m_`.  Rationale: the prefix already makes it clear that you are
>   referring to a member of the current class, so adding `this` would
>   just add noise.
> - Use `this` when referring to a method of the current class.
>   Rationale: without `this, it's not clear that you are referring to a
>   method of the current class, versus a free function.
> 
> ...
> 
> Any comments?  My intention would be to add this to the coding standards
> on the wiki.

This roughly amounts to turning C++ coding conventions into those of Python.  While I like the Python ones, it seems odd to force C++ style into something clearly not envisioned by its basic structure.

The fact that C++ requires "this" in a few obscure cases is due to messy add-ons like templates.  I don't see that as a reason to put "this" everywhere else.  

	paul


  reply	other threads:[~2021-08-13 14:46 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-13 14:26 Simon Marchi
2021-08-13 14:46 ` Paul Koning [this message]
2021-08-13 14:51   ` Simon Marchi
2021-08-13 14:47 ` Andrew Burgess
2021-08-15 13:34 ` Lancelot SIX
2021-08-16 16:40 ` Christian Biesinger
2021-08-16 16:59   ` Simon Marchi
2021-08-18 11:43     ` Ruslan Kabatsayev
2021-08-16 17:06 ` John Baldwin
2021-08-16 17:11   ` Simon Marchi
2021-08-16 17:23     ` Luis Machado
2021-08-16 17:31       ` Simon Marchi
2021-08-17 10:01       ` Andrew Burgess
2021-08-16 17:28     ` John Baldwin

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=01BE4175-EDDE-4B84-9FE8-B0C748BE0808@comcast.net \
    --to=paulkoning@comcast.net \
    --cc=gdb-patches@sourceware.org \
    --cc=simon.marchi@polymtl.ca \
    /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).