Floating point types default to NaN?

Michael V. Franklin slavo5150 at yahoo.com
Mon Nov 27 23:05:55 UTC 2017


On Saturday, 25 November 2017 at 22:13:43 UTC, Adam D. Ruppe 
wrote:

> It technically did:
>
> https://dlang.org/spec/function.html#local-variables
>
> "It is an error to use a local variable without first assigning 
> it a value. The implementation may not always be able to detect 
> these cases. Other language compilers sometimes issue a warning 
> for this, but since it is always a bug, it should be an error. "
>
>
> But that paragraph was never implemented (it is a bit easier 
> said than done to actually detect given if conditions and stuff 
> too, especially in the early days of D when the compiler didn't 
> even make any effort to track such things, though it does 
> now...). The compiler author took the easy way out of 
> initializing them to invalid values instead.

WOW!! I am shocked to learn this.  All this time, I though it was 
a design oversight.  I think I'm going to implement a feature 
gate to require explicit initialization.  It would be better to 
be strict up front and relax it as flow control analysis becomes 
more mature.

Mike



More information about the Digitalmars-d-learn mailing list