I think I have found one more reason for Nullable concept to appear in D:

Since SafeD disallows pointers, it needs something safe to replace them.

For example, it is impossible to use AA in SafeD, because opIn_r returns a 
pointer:

Foo[Bar] aa;

Bar bar = new Bar();
Foo* fooPtr = bar in aa; // this line is disallowed in SafeD

I wonder why it returns a pointer, and shouldn't it return Nullable!(Foo) (or 
just Foo? as an alias) instead?

Foo? foo = bar in aa; // null, if item is missing

Note that now it became slightly more efficient, because we don't need an 
additional pointer dereference, which was present when we returned Foo*!



Reply via email to