From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id pgV7LaibGmEQEQAAWB0awg (envelope-from ) for ; Mon, 16 Aug 2021 13:08:56 -0400 Received: by simark.ca (Postfix, from userid 112) id AE6B51EDFB; Mon, 16 Aug 2021 13:08:56 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-0.6 required=5.0 tests=MAILING_LIST_MULTI, RDNS_DYNAMIC autolearn=unavailable autolearn_force=no version=3.4.2 Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 5EC9E1E4A3 for ; Mon, 16 Aug 2021 13:08:56 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E16AD3951866 for ; Mon, 16 Aug 2021 17:08:55 +0000 (GMT) Received: from mx2.freebsd.org (mx2.freebsd.org [IPv6:2610:1c1:1:606c::19:2]) by sourceware.org (Postfix) with ESMTPS id 17AF73953420 for ; Mon, 16 Aug 2021 17:07:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 17AF73953420 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=FreeBSD.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [96.47.72.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits)) (Client CN "mx1.freebsd.org", Issuer "R3" (verified OK)) by mx2.freebsd.org (Postfix) with ESMTPS id EA6B095FA9; Mon, 16 Aug 2021 17:06:58 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [96.47.72.83]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GpLDf64gqz4ph9; Mon, 16 Aug 2021 17:06:58 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from John-Baldwins-MacBook-Pro.local (ralph.baldwin.cx [66.234.199.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) (Authenticated sender: jhb) by smtp.freebsd.org (Postfix) with ESMTPSA id 716D85249; Mon, 16 Aug 2021 17:06:58 +0000 (UTC) (envelope-from jhb@FreeBSD.org) To: Simon Marchi , Simon Marchi via Gdb-patches References: From: John Baldwin Subject: Re: Coding standards proposal, usage of "this" Message-ID: <4bd1cb46-fdcc-cb6a-c7ad-22aba3294772@FreeBSD.org> Date: Mon, 16 Aug 2021 10:06:57 -0700 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:78.0) Gecko/20100101 Thunderbird/78.12.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" On 8/13/21 7:26 AM, Simon Marchi via Gdb-patches 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. These seem fine to me. > - 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. This one feels a bit odd to me, though it may just be something I'm not used to. It is something I haven't seen used before in C++ at least. -- John Baldwin