OT: Leaving Rust gamedev after 3 years
claptrap
clap at trap.com
Mon Apr 29 19:22:41 UTC 2024
On Monday, 29 April 2024 at 18:53:24 UTC, bachmeier wrote:
>
> It's no more of a black hole than 0 or 1. It can be used to
> represent missing data, which is just as valid as 0 or 1. Does
> that mean it's a good choice for initialization of a double? I
> don't think so, but that does not justify using 0.
There's only one correct value to initialise the float too and
only the programmer knows what that is. The chances are that 0 is
alot more likely to be correct by accident than NaN is.
So the only argument for NaN is that it's easier to trace
forgotten initializations. (my experience is that it's no better
than 0)
But if you buy that argument then it logically follows that a
compiler error on missing initialization would be **far** more
effective at locating the bug.
Walters argument against that is that people will just slap zero
in there to silence the error. I would argue that they will do
exactly the same if it's NaN initialized, it'll just involve a
lot more effort to actually trace back to find out where to slap
the zero in.
More information about the Digitalmars-d
mailing list