(non)nullable types

Christopher Wright dhasenan at gmail.com
Sat Feb 14 05:37:04 PST 2009


Nick Sabalausky wrote:
> The "burning hoop", as you describe it, of checking a nullable var for null 
> before dereferencing is just simply something that the programmer should 
> already be doing anyway. Take the following case:
> 
> void Foo(void delegate()? dg) //nullable
> {
>     dg();
> }

You're right for that small example. Now let's say you have an object a 
dozen methods referencing the same nullable member. They're private 
methods called by public methods that check if the member is null first. 
I don't want to have to check whether the variable is null every single 
time I use it; I want to do it once at the start and assume (since it's 
a single-threaded application and I'm not assigning to that member) that 
that check works for everything.

I'm just fine with getting a segfault when using a nullable variable 
that's null. That's expected behavior.



More information about the Digitalmars-d mailing list