On Thu, Jan 15, 2009 at 2:38 AM, Denis Koroskin <[email protected]> wrote: > 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*!
How do you distinguish between the key being missing and there being a null reference in the AA? Also, if you have an AA like: Foo?[Bar] aa; What is the return type of in? "Foo??" ?
