Null references redux

bearophile bearophileHUGS at lycos.com
Tue Sep 29 15:35:43 PDT 2009


Jeremie Pelletier:

> Its dead easy to insert null into a nonnull reference,

If it's easy to put a null into a nonnull by *mistake*, then that system needs to be designed better.


> and since you 
> expect the type to never be null its the last thing you're gonna check.

I agree, but I think in a well designed system such situations are really uncommon.


> If variables are properly initialized, you'll never get null where you 
> don't expect it, and those are checked at compile time too, and work on 
> every type.

Cyclone is an example of language where there is both flow analysis (in a very C-like language that allows some kinds of gotos too, maybe someone here may read their source code and adapt it to D. [One of the weirder characteristics of open source programs is that hardly anyone ever reads/copies code/solutions from other open source projects; and I don't think those stupid/idiotic differences in OSS licences are enough to justify such behaviours. I think there's also a strong amount of NIH syndrome. So I don't hold my breath for the day when D will start working with mono C# devs to design a better GC that can be tuned and used for both such open source languages/implementations, that have different but not totally different GC needs]) and optional nonnull references (well, pointers). I think Cyclone shows how to design a safer C-like language. And making D safer is simpler than making C safer, despite D is more complex than C.

Bye,
bearophile



More information about the Digitalmars-d mailing list