From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id wUznLCeYLmUbXTAAWB0awg (envelope-from ) for ; Tue, 17 Oct 2023 10:20:23 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=simark.ca; s=mail; t=1697552423; bh=a0ydABlAFzPjxP3U6SWCqUMdSIx3T3DmiRh+ZhZ1ceY=; h=Date:Subject:To:Cc:References:From:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=K7X5/qXx7v7n7a8TZGA7EE+F+DyDicA06/zrq9jwwGmtpF06V/3kznodL/67MgvjM j7tzoUSexxJ69JEEKEzP2ka7jBAYiHb5bRQUClEPnopUACl1pfTFU6bgvJrdz/P7D7 EcJdThd7eO/p+swWCAAo9yA3g9DUevL/zIJ3lgUE= Received: by simark.ca (Postfix, from userid 112) id ACD1A1E0C1; Tue, 17 Oct 2023 10:20:23 -0400 (EDT) Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=simark.ca header.i=@simark.ca header.a=rsa-sha256 header.s=mail header.b=fPFf02Nc; dkim-atps=neutral Received: from server2.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 ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 85EE71E0BB for ; Tue, 17 Oct 2023 10:20:21 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E2522385770B for ; Tue, 17 Oct 2023 14:20:20 +0000 (GMT) Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id 500133858D33 for ; Tue, 17 Oct 2023 14:20:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 500133858D33 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=simark.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=simark.ca ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 500133858D33 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=158.69.221.121 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1697552411; cv=none; b=rywaz7N+Ra8jADTXbXHj/C7yK1vDYjyA1LKH1VwP8xRHYAM01E4vCtwrfPAYkvZms2AEMQsC4iDC+z3oedVU68Z/ilYipeVoyVRNesTRtdZOVKOawXA3YgVzGjkQugNZrGJSDs7MAhX67eVtdN1Zchjq8DFvjFk3uBrEWSY5sws= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1697552411; c=relaxed/simple; bh=a0ydABlAFzPjxP3U6SWCqUMdSIx3T3DmiRh+ZhZ1ceY=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=BfC4GlEvVyMDObXBScU6tzetiIAGO2GY0D+rvXvOrGdQgCmORk21syXR7AygwxQoi5U0p0pRrKMXP+mo4q5cx61Y3tiJREc2Lo8g9GazweX/SnfMern0mdsU+yrFJzOUCZgigcKs60YAdh/73nvmPu9xhwuJpylMsX8VSkcqK90= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=simark.ca; s=mail; t=1697552409; bh=a0ydABlAFzPjxP3U6SWCqUMdSIx3T3DmiRh+ZhZ1ceY=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=fPFf02Nc1L+GtfANHldSKiNRlTZEv3t6bNpjekNc+eQGvYLusfvJEHRfwk5hI2ria TjP0lR29M81y0CpU60Gf82iePKKkeXohZ3gSCMEkAr6qk+4X2bnakp10kegnWh7fPj bSHSHmjiO9FCrBX4Dp3vmhiOLMGsmiA6QmI8cMgs= Received: from [172.16.0.192] (192-222-143-198.qc.cable.ebox.net [192.222.143.198]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 7A3811E00F; Tue, 17 Oct 2023 10:20:09 -0400 (EDT) Message-ID: <9157618b-4086-4f64-861d-a95fa529688a@simark.ca> Date: Tue, 17 Oct 2023 10:20:09 -0400 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 06/11] gdb: Use std::string_view instead of gdb::string_view To: Lancelot SIX , Pedro Alves , Tom Tromey Cc: gdb-patches@sourceware.org References: <20231013144418.3180617-1-lancelot.six@amd.com> <20231013144418.3180617-7-lancelot.six@amd.com> <87il78x49e.fsf@tromey.com> <87zg0iqs1p.fsf@tromey.com> Content-Language: fr From: Simon Marchi In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 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 On 10/17/23 10:13, Lancelot SIX wrote: > Hi, > > On 16/10/2023 22:51, Pedro Alves wrote: > >>> Lancelot> + std::string_view name; >>> Lancelot> + if (const char *name_str = keyname (ch); >>> Lancelot> + name_str != nullptr) >>> >>> We should probably discuss whether to allow this construct before >>> letting it in. >>> >>> Personally I'm ok with it. >> >> I think it may look a little weird if you're not used to it (like I am not), but >> OTOH it isn't really different from introducing a variable to scope with "for", like: >> >> for (const char *name_str = keyname (ch); >> name_str != nullptr; ....) >> .... >> >> so I suspect we'll all just get used to it and think nothing of it in a few years. >> >> So am I fine with it too. >> > > I don't mind not using this for now. The "name_str" will be declared outside of the if scope for now. > > If this construct is comes in, there will also be the question of coding style (i.e. single line if line length permits or multiple lines as I did here). I guess we could go the same way we do for "for" and prefer single line. I didn't even know this construct existed, I was a bit shocked at first :P. But once you said "it's just like for", it looked just fine to me. Declaring variables in the narrowest scope possible has its technical merits, so I think we should allow that construct. I think it's fine to put it on one line if it fits. Simon