From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.polymtl.ca (smtp.polymtl.ca [132.207.4.11]) by sourceware.org (Postfix) with ESMTPS id 6BA323857C5B for ; Fri, 30 Jul 2021 02:10:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6BA323857C5B Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id 16U29agB021335 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 29 Jul 2021 22:09:41 -0400 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 16U29agB021335 Received: from [10.0.0.11] (192-222-157-6.qc.cable.ebox.net [192.222.157.6]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 141391EA7E; Thu, 29 Jul 2021 22:09:36 -0400 (EDT) Subject: Re: [PATCH 15/16] gdb: make cmd_list_element var an optional union To: Lancelot SIX , Tom Tromey Cc: Lancelot SIX via Gdb-patches 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> <20210729201235.h4b7mbvzxu2rnckr@ubuntu.lan> From: Simon Marchi Message-ID: Date: Thu, 29 Jul 2021 22:09:35 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.12.0 MIME-Version: 1.0 In-Reply-To: <20210729201235.h4b7mbvzxu2rnckr@ubuntu.lan> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Fri, 30 Jul 2021 02:09:36 +0000 X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, NICE_REPLY_A, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, 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: Fri, 30 Jul 2021 02:10:47 -0000 On 2021-07-29 4:12 p.m., Lancelot SIX via Gdb-patches wrote: > 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. There is some gain in safety... in that it could catch some mistakes at compile time. I don't really have an opinion on when the amount of template complexity gets too high compared to the 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). Would the get_string/set_string/get_int/set_int methods still assert that the var_type matches the storage type accessed? I think that's important to have. Simon