Jonathan M Davis:
> Considering that other major languages such as C# and Java do these checks 
> with 
> every dereference (though they may optimize it out in some cases), I don't 
> think 
> that it's at all unreasonable to have them in D. They'd be a huge boon to 
> debugging. Now, since D is as concerned about efficiency as it is (being a 
> systems 
> language), it makes sense that those checks would be removed in release mode, 
> but I still think that it would be a very good idea to have them in debug 
> mode.

C# and Java are badly designed, D may do better. In my opinion a better 
solution to this problem is to:
1) Introduce non-nullable pointers/references, to denote them I have proposed a 
trailing @.
2) Require explicit tests every time a nullable pointers/references is about to 
be dereferenced (and then after this test in the else branch the reference type 
"becomes" a non-nullable one. This is an application of the idea of 
"TypeState", used by the Mozilla Rust language. The type doesn't actually 
change, it's just its state that changes...).

This way you don't need (most) implicit null checks.

Bye,
bearophile

Reply via email to