From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id DUETGsefGmHaEQAAWB0awg (envelope-from ) for ; Mon, 16 Aug 2021 13:26:31 -0400 Received: by simark.ca (Postfix, from userid 112) id 4FDB21EDFB; Mon, 16 Aug 2021 13:26:31 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.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 B24281E4A3 for ; Mon, 16 Aug 2021 13:26:30 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3877939540BF for ; Mon, 16 Aug 2021 17:26:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3877939540BF DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1629134790; bh=6TIlklb5B1GyWPP6sb+i2zy+KqBx5V2bPKkiZYNB3Os=; h=Subject:To:References:Date:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=GgVk1hqs0LxE+w+vX1fSa7Lu2cecEhnHQEhSo//4PphiipsRTuWi2G1aVSgKsfrrm NIuZmC4Su+1FqfOd+QcvpBFs4nvmnYe1wHpLFBjTs17r5/0/52IYI/GET7EHIovHZ6 lL2esJSGULHi3MILWaZ127gBs7FWy+VNrpSfCKIc= Received: from mail-pj1-x102c.google.com (mail-pj1-x102c.google.com [IPv6:2607:f8b0:4864:20::102c]) by sourceware.org (Postfix) with ESMTPS id 525ED39540EC for ; Mon, 16 Aug 2021 17:23:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 525ED39540EC Received: by mail-pj1-x102c.google.com with SMTP id j1so27644529pjv.3 for ; Mon, 16 Aug 2021 10:23:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=6TIlklb5B1GyWPP6sb+i2zy+KqBx5V2bPKkiZYNB3Os=; b=bXERL62mmVKZhYlB8KVu9AQfM3NjgYn6/lovDR2KUnK1JSKcJx2YmmaH/jPRbxvezp Akqrqo1PmfyxKvHiTX8x3mLUA3ZYZl9oZiT0RcPJDmM5BPODiLzWyW8dYT2jvuTVoAb+ X4Rl4fza2C9rdAxOy9iOIhyg6XAGR5f5qoZe/N8dRqzFExtRTs4Ywbl51USesYGE+bcu mhATiQMq/gEcenVQ5qhmxq4rxC7/KOHKxSy0ZwlEW9Oi66gMaFRl2xYf7C9xqZ+nsTL5 lWuZBhNrzIf1Tg2COzGHTrMk6AbSsQiOmyJYiVJPZVSHOH9lbhcH+HdTbsqGvsiebY5E Lgpw== X-Gm-Message-State: AOAM5335bcmI/RfXC2p21iwHDc/0xSdaH+Gl1HVc58exBXrxmpBA/QJm PDUkHXn6w0QMok4NKV1s/k6hjIkaoOxBjA== X-Google-Smtp-Source: ABdhPJy2uRE9akI625SKngYxKRa/qzLD4qY1z9CxrfHxrZHZW2uRecSAzKK1nEU56rRJIYlhl25LmA== X-Received: by 2002:a63:b59:: with SMTP id a25mr16766943pgl.373.1629134626453; Mon, 16 Aug 2021 10:23:46 -0700 (PDT) Received: from ?IPv6:2804:7f0:4841:25bc:c427:9a2f:ff20:db8d? ([2804:7f0:4841:25bc:c427:9a2f:ff20:db8d]) by smtp.gmail.com with ESMTPSA id i5sm70203pjk.47.2021.08.16.10.23.44 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 16 Aug 2021 10:23:45 -0700 (PDT) Subject: Re: Coding standards proposal, usage of "this" To: Simon Marchi , John Baldwin , Simon Marchi via Gdb-patches References: <4bd1cb46-fdcc-cb6a-c7ad-22aba3294772@FreeBSD.org> <00698c41-1af7-b9a8-f127-449a1a06911c@polymtl.ca> Message-ID: <1fd0ea1c-7226-62a0-0568-6793a41ab9a7@linaro.org> Date: Mon, 16 Aug 2021 14:23:42 -0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <00698c41-1af7-b9a8-f127-449a1a06911c@polymtl.ca> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit 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: Luis Machado via Gdb-patches Reply-To: Luis Machado Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" 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. I suppose it is just the nature of C++. Some constructs are just not great when trying to read/parse them. I think the same happens with some templates and lambda's. It might take a little bit to figure out where the functions are defined. Given GDB's code base is a mix of C and C++, wouldn't we risk having yet another mix of new coding standards with old coding standards?