Null references (oh no, not again!)

Michel Fortin michel.fortin at michelf.com
Tue Mar 3 19:29:45 PST 2009


On 2009-03-03 13:59:16 -0500, Andrei Alexandrescu 
<SeeWebsiteForEmail at erdani.org> said:

> I suggested to Walter an idea he quite took to: offering the ability of 
> disabling the default constructor. This is because at root any null 
> pointer was a pointer created with its default constructor. The feature 
> has some interesting subtleties to it but is nothing out of the 
> ordinary and the code must be written anyway for typechecking invariant 
> constructors.
> 
> That, together with the up-and-coming alias this feature, will allow 
> the creation of the "perfect" NonNull!(T) type constructor (along with 
> many other cool things). I empathize with those who think non-null 
> should be the default, but probably that won't fly with Walter.

That'd be great, really.

But even then, NonNull!(T) will probably be to D what auto_ptr< T > is 
to C++: a very good idea with a very bad syntax only expert programmers 
use. C++ makes the safest pointer types the less known; please convince 
Walter we shouldn't repeat that error in D.


-- 
Michel Fortin
michel.fortin at michelf.com
http://michelf.com/




More information about the Digitalmars-d mailing list