null and type safety

Mike Hearn mike at plan99.net
Fri Nov 28 13:49:08 PST 2008


> The basic problem is that it's hard to integrate a language with non-
> nullable types with libraries written without them (e.g. when auto-
> generating bindings with BCD). This would likely be a big problem for D, 
> since integrating with existing C and C++ code is a major feature.

Can't that be solved by reversing the syntax, ie, you mark variables that cannot be null rather than variables that can be. The compiler then requires you to prove the non-nullness of the value on that codepath (or cast it away with nonnull).

I'd love to see non-null types in D2. Intuitively, it'd catch at compile time quite a few bugs I see in my programs (assuming a strong compiler analysis).



More information about the Digitalmars-d mailing list