Spec#, nullables and more

bearophile bearophileHUGS at lycos.com
Sat Nov 6 12:27:50 PDT 2010


Walter:

> retard wrote:
> > In a functional language:
> > 
> > start_the_car c = case c of
> >   Just car -> start car
> >   Nothing -> error "not initialized"
> 
> And the null pointer exception is reinvented!

That "case" statement (is a pattern matching) forces you to manage the null case everywhere you use a Nothing-able type like that, otherwise your program doesn't compile. In a language like D the compiler doesn't remind you to manage the null case, so you may forget it. And experience shows that indeed in many people around the world forget to test it and important programs stop running. When you are running a program, it's not nice to see it stop in the middle of its work.

This request of explicit management of nulls is indeed the second half of the nonnull proposal I have explained in my enhancement request. There are several ways to face this in D, and so far only a person in this thread has touched this second part of the proposal.

Bye,
bearophile


More information about the Digitalmars-d mailing list