Movement against float.init being nan

Dom Disc dominikus at scherkl.de
Mon Aug 22 19:49:02 UTC 2022


On Monday, 22 August 2022 at 15:04:25 UTC, claptrap wrote:

> You dont initialise all variables to zero, Ive just looked at 
> some om my code and in 4000 lines i found two default init ints 
> and maybe 50+ explicitly initialised.

So, if you rarely ever use default initialization, why do you 
care to which value it might be initialized?

For the analysis which default value is the better one, only the 
cases where it is used matters.
You need only count how often is a variable not initialized, and 
of those how many times is this (a) a bug or (b) intended.

Now imagine you review code from someone else (e.g. at an 
assessment). In this case you have to carefully check every case 
of uninitialized variable. If the code always explicitly say 
=void or =0, there are no such cases, so you might save a LOT of 
time.

So better get used to ALWAYS initialize explicitly and consider 
EVERY occurrence of uninitialized variable to be a bug. And bogus 
code should NEVER result in a value that could also occur as a 
valid result, so the compiler should help as much as it can by 
using an invalid value if one is available.


More information about the Digitalmars-d mailing list