deprecate boolean evaluation of floating point and character types
Daniel N
no at public.email
Tue Apr 30 19:28:14 UTC 2024
On Tuesday, 30 April 2024 at 18:09:22 UTC, Richard (Rikki) Andrew
Cattermole wrote:
> Characters are quite often compared against zero when doing
> string handling in C without the binary expression. For this
> reason I would not want to see this changed.
>
>
>
> Now floats on the other hand... there is no clear truthiness
> value associated with them, unless IEEE-754 defines one (it
> doesn't appear to for 2008 version).
>
> C23 appears to not define if a floating point type can even
> convert to bool, although it does mention bool as not being
> supported in multiple places.
I think the most useful conversion would be.
NaN -> false
because that corresponds to .init
Futhermore you can't simply use == to compare with NaN you need
to call isNan(), which complicates writing generic code.
More information about the dip.ideas
mailing list