lmi
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lmi] [PATCH] Small fix for "unsafe comparison" warning in MSVS buil


From: Greg Chicares
Subject: Re: [lmi] [PATCH] Small fix for "unsafe comparison" warning in MSVS build
Date: Thu, 12 Jul 2018 17:28:09 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0

On 2018-07-10 22:32, Vadim Zeitlin wrote:
> On Tue, 10 Jul 2018 20:31:20 +0000 Greg Chicares <address@hidden> wrote:
[...]
> GC> Even if this really is the only occurrence of this warning, the code seems
> GC> perfectly clear and correct to me,
> 
>  I'm surprised. Assigning a double to a boolean, as the current code does,
> is a huge red flag for me. Do you really condone such type-unsafeness?

Here we're using 'double' as a general numeric type, so that we can hold
all output values in a homogeneous container, even though some of the
values are really integral or boolean. In twentieth-century C dialects,
I grew accustomed to writing code like:
  double really_boolean = 1;
  if(really_boolean) ...
when there wasn't even a boolean type to cast to. I'd rather write
  if(!!really_boolean)
but long ago I made the mistake of reserving '!!' for specialized comments,
so 'make check_concinnity' chokes on bang-bang in code.

I suppose I could write
  if(not not really_boolean)
but that's awfully weird. I really ought to '%s/!!/?!/g *' but that's a
pretty big task.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]