From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lndn.lancelotsix.com (vps-42846194.vps.ovh.net [IPv6:2001:41d0:801:2000::2400]) by sourceware.org (Postfix) with ESMTPS id 0C85B3858012 for ; Thu, 29 Jul 2021 20:12:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 0C85B3858012 Received: from ubuntu.lan (unknown [IPv6:2a02:390:9086::635]) by lndn.lancelotsix.com (Postfix) with ESMTPSA id D55FE83DDA; Thu, 29 Jul 2021 20:12:39 +0000 (UTC) Date: Thu, 29 Jul 2021 20:12:35 +0000 From: Lancelot SIX To: Tom Tromey Cc: Lancelot SIX via Gdb-patches Subject: Re: [PATCH 15/16] gdb: make cmd_list_element var an optional union Message-ID: <20210729201235.h4b7mbvzxu2rnckr@ubuntu.lan> References: <20210714120851.3pfew5pgcdp6ezn6@ubuntu.lan> <20210714171238.vzccwpurh2izbkps@ubuntu.lan> <20210714232112.wsn7pits6uuz3nf5@ubuntu.lan> <20210720230335.dcpfxbol2uwjre3b@Plymouth> <87sfzyci3i.fsf@tromey.com> <20210728204538.z3iqkcfp7yenehms@ubuntu.lan> <87eebhau75.fsf@tromey.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <87eebhau75.fsf@tromey.com> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.5.11 (lndn.lancelotsix.com [0.0.0.0]); Thu, 29 Jul 2021 20:12:40 +0000 (UTC) X-Spam-Status: No, score=-5.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, 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: Thu, 29 Jul 2021 20:12:43 -0000 On Thu, Jul 29, 2021 at 11:47:10AM -0600, Tom Tromey wrote: > >>>>> "Lancelot" == Lancelot SIX writes: > > Lancelot> Would you prefer to have something like var.get () return a > Lancelot> string happily if var is lets say a var_filename but fail if it is a > Lancelot> var_boolean? > > Yeah. > > Lancelot> I guess it is possible, but I did intentionally went for a very explicit > Lancelot> approach. The idea is to have the user of the class state that he is > Lancelot> aware he will access a data of a given type that can be interpreted in > Lancelot> different ways. This kind of makes more sense when dealing with the > Lancelot> various var_*integer* types where the same value can have different > Lancelot> meaning depending on the effective var_type. > > I don't understand how to reconcile this with the idea that one could > pass in a bunch of var_ parameters and get some result back. > Like does get work? Yes, given that both var_integer and var_zinteger use a int*, this would work. However, something like get will fail to compile because var_uinteger uses unsigned int* while var_zuinteger uses a int*. > > I guess the argument would be that the author of that line is supposed > to understand what's happening and that the meaning of the value might > "vary"? It is the original idea. Multiple "var_types" can share the same storage type while still being different logical types (a given value is to be interpreted differently based on the actual type). The original idea was to use it in a 'get' way but this was conflicting with how this is used. I followed that path to see where it lead. > For me that seems to add a bunch of extra template code but > without any real gain in safety. I’ll revisit all of this in a V2 later. I was worried about the amount of template boilerplate this adds compared to the value it brings, I should have worried a bit more! If I strip the extra template noise, this can come down to some get_string/set_string/get_int/set_int and so on. The 'get' can be a light abstraction on top of that, if ever needed (I am not sure it is). Thanks for the comments, much appreciated. Best, Lancelot. > > Tom