Null references (oh no, not again!)

bearophile bearophileHUGS at lycos.com
Wed Mar 4 02:24:19 PST 2009


Andrei Alexandrescu:
> I did some more research and found a study:
> http://users.encs.concordia.ca/~chalin/papers/TR-2006-003.v3s-pub.pdf
> ...
> Turns out in 2/3 of cases, references are really meant to be non-null... 
> not really a landslide but a comfortable majority.

Thank you for bringing real data to this debate.
Note that 2/3 is relative to nonlocal variables only:

>In Java programs, at least 2/3 of declarations (other than local variables) that are of 
reference types are meant to be non-null, based on design intent.
We exclude local variables because their non-nullity can be inferred by intra-procedural 
analysis<

So the total percentage may be different (higher?).
Anyway, nonnullable by default seems the way to go if such feature is added.

Bye,
bearophile



More information about the Digitalmars-d mailing list