The NaN of types (in D)

Paul Backus snarwin at gmail.com
Mon Oct 12 14:11:22 UTC 2020


On Monday, 12 October 2020 at 07:57:11 UTC, Joseph Rushton 
Wakeling wrote:
> On Sunday, 11 October 2020 at 20:37:56 UTC, Paul Backus wrote:
>>
>> Given that null references for classes are widely considered a 
>> "billion dollar mistake" [1], the comparison does not exactly 
>> fill me with confidence.
>
> Is that really a valid comparison, though?  Doesn't the issue 
> with null references for classes stem from memory safety 
> concerns?
>
> I don't quite see how that applies in the case of types, any 
> more than NaN is a safety issue for floating point numbers.

The issue with null references is not related to memory safety. 
NullPointerException in Java is not a memory-safety error, for 
example. The issue with nullable references is that you have to 
check every reference for null before you use it, or your program 
will crash.

By contrast, NaN will not crash your program if you forget to 
check for it before using it in an expression.


More information about the Digitalmars-d mailing list