null dereference exception vs. segfault?

bearophile bearophileHUGS at lycos.com
Mon Aug 2 15:02:01 PDT 2010


Pelle:

> Null Pointer Exception!

Ah, I see. I hate TLA (Three Letter Acronyms).


> What I really wish for is non-nullable types, though. Maybe in D3... :P

I think there is no enhancement request in Bugzilla about this, I will add one.

To implement this you have to think about the partially uninitialized objects too, this is a paper about it, given a class type T it defines four types (I think the four types are managed by the compiler only, the programmer uses only two of them, nullable class references and nonnullable ones):
http://research.microsoft.com/pubs/67461/non-null.pdf

If a language defaults to nonnullable references, then you can use this syntax:

class T {}
T nonnullable_instance = new T;
T? nullable_instance;

But now it's probably nearly impossible to make D references nonnullable on default, so that syntax can't be used. And I don't what syntax to use yet. Suggestions welcome.

Bye,
bearophile


More information about the Digitalmars-d-learn mailing list