Non-null objects, the Null Object pattern, and T.init
Michel Fortin
michel.fortin at michelf.ca
Thu Jan 16 20:00:24 PST 2014
On 2014-01-17 01:42:37 +0000, Andrei Alexandrescu
<SeeWebsiteForEmail at erdani.org> said:
> Walter and I were talking today about the null pointer issue and he had
> the following idea.
>
> [...]
>
> Thoughts?
Which null pointer issue were you discussing exactly?
The one I'm mostly concerned about is the propagation of a null value
from point A to point B in a program, where you only detect the null
value at point B through a null dereference making it hard to figure
out from where this unexpected null value comes from. Replace 'null'
with 'sentinel' and it's no easier to figure out where the invalid
value comes from. Except now instead of checking for null you have to
check for null *and* for T.init *and* for all the various Sublcass.init
you might get.
The idea is interesting, but I see it creating more problems than it
would solve. I'm not even sure I understand what problem it tries to
solve.
--
Michel Fortin
michel.fortin at michelf.ca
http://michelf.ca
More information about the Digitalmars-d
mailing list