Keyword to avoid not null references

Namespace rswhite4 at googlemail.com
Mon Apr 23 00:14:12 PDT 2012


I made several tests with NotNull yesterday and actually they all 
passed.
In special cases i didn't get a compiler error but then a runtime 
error is better then nothing. :)

But there is still my problem with this:

void foo(NotNull!(Foo) n) {

}

void bar(Foo n) {

}

in my optinion it must exist a way that both
NotNull!(Foo) nf = new Foo();

foo(nf);
bar(nf);

and furhtermore
Foo f = new Foo();

foo(f);
bar(f);

compiles.
We need some hack, implicit cast or compiler cast that cast or 
passes Foo to NotNull!(Foo).

Any suggestions?


More information about the Digitalmars-d-learn mailing list