Is there a strong reason for Nullable's alias get this?

FeepingCreature feepingcreature at gmail.com
Mon Apr 16 10:06:59 UTC 2018


Say that we have a function that returns an int. We assign it to 
an auto variable and pass that to another function which takes an 
int. All is well.

Say we change the function to return a Nullable!int. We expect 
the compiler to warn us that we must now check for isNull; 
however, what we actually get is a runtime crash! It's almost 
like we're writing Javascript!

Say we have a function that takes a Nullable!int. However, we 
want to change the function to merely take an int, and move the 
isNull check outside it. However, we again face a runtime crash 
instead of a compiler warning.

Say we are simply misremembering the return type of a function. 
Say the call is in a little-used part of the code, just lying in 
wait to crash our application.

This is not good, and it's not how you would expect a statically 
typed language to behave.


More information about the Digitalmars-d mailing list