From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by sourceware.org (Postfix) with ESMTPS id 9A62E383541E for ; Tue, 17 Aug 2021 10:01:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 9A62E383541E Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=embecosm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=embecosm.com Received: by mail-wr1-x42d.google.com with SMTP id z9so27625574wrh.10 for ; Tue, 17 Aug 2021 03:01:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=0J7/Qn8AWk8U1vEmGfxSXc0WN3EnsVJBxi5BGgK/zNA=; b=YafY+y8ntekxk71KFWNNEFnPocktMeUYgoQAedEiKyy6gEHQOMmVY0FG+jH8ZocOxn mKZFbiHtBChUvBUwTkG/lfIvwaWjTXv/Sc4au+3L+h5wEVN2+3ypYip8ZRSWDnO/L5zT kCxKmMIfwDFXSo2MeKhOU09ILZulOuFspi73NPUpUAAYlPWXDUtUOAhHRKaDGMojD8H1 37vc5clT8IaecLkk3HsWO3RB03tjsI8QxzYc+aVBrDjSWHTXt8RELsUoTnIM7DK7Eljb nt/5TdzhE013nm/YrBvvuBh+RYz4yA+mNPqroPuCdwlHqzPgx5fjNMSabMzHZu8zCIPw aQmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=0J7/Qn8AWk8U1vEmGfxSXc0WN3EnsVJBxi5BGgK/zNA=; b=sTtek7EzDYSen4W1dxtm19lOCop8YeR0THWwqND570w4N4OKm+xkrOVTG3l7fxNG47 yChC0tgPlxDXkGoO/W0FJWyO+tYzWvfN2y6if5AZ9AUAn3fq+u1MYpxgk7tg7prNAYbZ AqP9yPHVt6nlfe3efJY+IDFNCAvlFLRCP6v6ld+wFvbZb5MqPvNSRCYgsPNxkExJyGCT +0oBBRkT/3SSF7cfoSBNDQUusVKb1PZD8x/JOTfeF9iAghCdc3WiOMsc58tGhxT0gSTI mbMN+JB5ooROUjp+9W+op8HGeKHcWbfdAz/QpMNlrxCwerEBVVW5f+TDL+VzTr54Ovtl LS5w== X-Gm-Message-State: AOAM532mXw+eI58uERPlgmRjnm3Od0BZKHGUvLwJaGGwRaVBMClXeCJd DKVkSm6kYWEgfQHEDEa7tipPcg== X-Google-Smtp-Source: ABdhPJy4oo6Gbkz69ta7PK0kC4DREoiBwoB0YLdBwYd86v02iLHJ2lzQS5qW2e69OnNs7qZDAqK2Sw== X-Received: by 2002:adf:d227:: with SMTP id k7mr2976733wrh.392.1629194476793; Tue, 17 Aug 2021 03:01:16 -0700 (PDT) Received: from localhost (host86-175-180-250.range86-175.btcentralplus.com. [86.175.180.250]) by smtp.gmail.com with ESMTPSA id u23sm1568644wmc.24.2021.08.17.03.01.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Aug 2021 03:01:16 -0700 (PDT) Date: Tue, 17 Aug 2021 11:01:15 +0100 From: Andrew Burgess To: Luis Machado Cc: Simon Marchi , John Baldwin , Simon Marchi via Gdb-patches Subject: Re: Coding standards proposal, usage of "this" Message-ID: <20210817100115.GM462163@embecosm.com> References: <4bd1cb46-fdcc-cb6a-c7ad-22aba3294772@FreeBSD.org> <00698c41-1af7-b9a8-f127-449a1a06911c@polymtl.ca> <1fd0ea1c-7226-62a0-0568-6793a41ab9a7@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1fd0ea1c-7226-62a0-0568-6793a41ab9a7@linaro.org> X-Operating-System: Linux/5.8.18-100.fc31.x86_64 (x86_64) X-Uptime: 10:58:59 up 15 days, 15:39, X-Editor: GNU Emacs [ http://www.gnu.org/software/emacs ] X-Spam-Status: No, score=-5.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org 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: , X-List-Received-Date: Tue, 17 Aug 2021 10:01:28 -0000 * Luis Machado via Gdb-patches [2021-08-16 14:23:42 -0300]: > On 8/16/21 2:11 PM, Simon Marchi via Gdb-patches wrote: > > On 2021-08-16 1:06 p.m., John Baldwin wrote: > > > 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. > > > > So, the first two seem to be more accepted, and this last one less. I'd > > be fine just going with the first two then (even though in my opinion > > the reason for using `this` to refer to a non-prefixed data member > > applies the same when referring to a non-prefied member function). > > My 2 cents. I wouldn't mind the change, but having to remember when to use > "this" and when not to use it is worse to me than spending a couple minutes > trying to figure out why the code is the way it is. Except most code is written once, and debugged many times. So in the long run it's much more efficient to spend a minute longer writing the code, even if it saves just a few seconds off reading (and understanding) the code. IMHO, of course :) Thanks, Andrew