SafeD and Nullable concept
Denis Koroskin
2korden at gmail.com
Wed Jan 14 23:38:36 PST 2009
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*!
More information about the Digitalmars-d
mailing list