[phobos] phobos commit, revision 1552

Adam Ruppe destructionator at gmail.com
Wed May 26 18:52:52 PDT 2010


Walter Bright wrote:
>  If I didn't have null pointers, I'd have to write a special "end of list" object. What should that object do if accessed? Throw an exception.

The idea here isn't to get rid of them, but to catch improper use
statically. The language would still have null pointers.

Consider a function like this:

void foo ( Object o )
in {
      assert( o !is null);
}
body {
       o.whatever();
}

The idea with having not-null references is to put that contract in
the type signature, so you can catch it at compile time instead of run
time. But, null pointers are still allowed if you don't specify the in
contract (or if you don't use the hypothetical NotNull type).


More information about the phobos mailing list