From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id R5PaF0SVGmGkEAAAWB0awg (envelope-from ) for ; Mon, 16 Aug 2021 12:41:40 -0400 Received: by simark.ca (Postfix, from userid 112) id 4EF111EDFB; Mon, 16 Aug 2021 12:41:40 -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.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RDNS_DYNAMIC,URIBL_BLOCKED autolearn=ham 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 880A31EA7E for ; Mon, 16 Aug 2021 12:41:39 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id F0D8A3951402 for ; Mon, 16 Aug 2021 16:41:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org F0D8A3951402 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1629132099; bh=JCUtIlpydrod2IvU//HdJ9oUke0c+ppUYuSE54BWyZ8=; h=References:In-Reply-To:Date:Subject:To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=thf/CcipuRf1QVNnQ5E3PAjUGPLpRPfTltScXPUlJtN95p4K/DDqFuMF7tag3xhZ6 2snGUTkUQIYRC8GO209JuevfWA9vBjc8SY5w7zIjgNaWKI5bZLH99AUuKrMRKw4KBK fFIwoQsY+eG/xvDBatOPTXyETL/TmlvFU3c1oS+w= Received: from mail-qk1-x732.google.com (mail-qk1-x732.google.com [IPv6:2607:f8b0:4864:20::732]) by sourceware.org (Postfix) with ESMTPS id 7A3AB385742B for ; Mon, 16 Aug 2021 16:41:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 7A3AB385742B Received: by mail-qk1-x732.google.com with SMTP id p22so18536893qki.10 for ; Mon, 16 Aug 2021 09:41:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=JCUtIlpydrod2IvU//HdJ9oUke0c+ppUYuSE54BWyZ8=; b=dpdbxDO/s0nE3LUyxrHFhviD8KOngJedwvA3vgCPtRSuH4bkoUWCyASj7JBhpciRcJ N6LDftutzSdQzbXq01HMQBcc5A02iUqjykm7eEBh3dmc8uXsE2i9mGWdeQW0hVD/+3me gHlLqWQ73IpwDXZMxF3gifg2ivNapx8wHSfuxGZuU/l7wnVqQDmafjtnhy5PN1h0oYL9 0chbjTvhYnI+ZqB5+F4O67d77kuT8o5BGMIH3QZMW68yHD6CGx60mOdRS4LP065gv9h7 2+/SiT6U7xCyNbH2YfpwgL7r7hsoC+LyyIogybJ092z7nszV8PF0ty8dX8wwhLy6c/WT g/PA== X-Gm-Message-State: AOAM533RqUpXmferDa7hcXiqsd0UC8TBAyzZwXkMTC/2GIIQ9VGHVZtz WYnm1taSF4MUFIDlOTOTUuHSaCotTxsQlz+7YpQAHA== X-Google-Smtp-Source: ABdhPJw7qGEJvSZ1UHyegFnIWpE7UgCHRRobtEEH8etyAkg+wOOawEGQfZUaT2pDI9jmPn2hhCeuuTBJOlppdpZfeNg= X-Received: by 2002:a37:a613:: with SMTP id p19mr16320274qke.28.1629132079868; Mon, 16 Aug 2021 09:41:19 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Mon, 16 Aug 2021 12:40:42 -0400 Message-ID: Subject: Re: Coding standards proposal, usage of "this" To: Simon Marchi Content-Type: text/plain; charset="UTF-8" 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: , From: Christian Biesinger via Gdb-patches Reply-To: Christian Biesinger Cc: Simon Marchi via Gdb-patches Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" On Fri, Aug 13, 2021 at 10:27 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. Those two seem good. > - 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. I'm not really a fan of this, and I am also not aware of other projects using such a style. Since this makes calling member functions more verbose/uglier than calling free functions, this would also discourage member functions. Is there a need to distinguish these? Christian