Re: [PATCH 00/16] Add styling to the gdb CLI and TUI

Simon Marchi
2019-03-21T18:08:39Z

On 2019-03-21 1:02 p.m., Eli Zaretskii wrote:
>> Cc: tom@tromey.com, gdb-patches@sourceware.org
>> From: Pedro Alves <palves@redhat.com>
>> Date: Thu, 21 Mar 2019 16:12:26 +0000
>>
>> Is there an advantage of a single variable that encodes the version,
>> compared to separate major/minor variables?
>
> Just that it makes comparison simpler, and IME less error-prone. Not
> a very important argument, admittedly.
>

Yeah, if you want to check if you are running 8.5 or more, you can do:

if $_gdb_version >= 805

With separate components, you have to do something like

if $_gdb_version_major >= 9 \
|| ($_gdb_version_major >= 8 && $gdb_version_minor >= 5

If you need to check for a range, it's even more complicated.

But then, if the version is provided as separate components, nothing
prevents you to re-encode it however you want after that. You can do
easily enough

set $my_gdb_version = ($_gdb_version_major * 100) + $_gdb_version_minor

if you want, and use the simple comparison. And everyone is free to
choose their own encoding :). So, to me separate components sounds better.

Simon