Common ground. Re: Null references redux
Don
nospam at nospam.com
Tue Sep 29 04:26:47 PDT 2009
Walter Bright wrote:
> Denis Koroskin wrote:
> > On Sat, 26 Sep 2009 22:30:58 +0400, Walter Bright
> > <newshound1 at digitalmars.com> wrote:
> >> D has borrowed ideas from many different languages. The trick is to
> >> take the good stuff and avoid their mistakes <g>.
> >
> > How about this one:
> >
> http://sadekdrobi.com/2008/12/22/null-references-the-billion-dollar-mistake/
>
> >
> >
> > :)
>
> I think he's wrong.
>
> Getting rid of null references is like solving the problem of dead
> canaries in the coal mines by replacing them with stuffed toys.
Let's go back a step. The problem being addressed is this: inadvertent
null references are an EXTREMELY common bug in D. For example, it's a
bug which *every* C++ refugee gets hit by. I have experienced it
ridiculously often in D.
*** The problem of null references is an order of magnitude worse in D
than in C++, because classes in D use reference semantics. ***
Eliminating that category of bug at compile time would have a huge
benefit for code quality. "Non-nullable references by default" is just a
proposed solution. Maybe if D had better flow analysis, the demand for
non-nullable references wouldn't be so great.
(Neither is a pure subset of the other, flow analysis works for all
variables, non-nullable references catches more complex logic errors.
But there is a very significant overlap).
Interestingly, while working on CTFE, I noticed that the CTFE code has a
lot in common with flow analysis. I can easily imagine the same code
being reused.
More information about the Digitalmars-d
mailing list