Null references redux

Jeremie Pelletier jeremiep at gmail.com
Sat Sep 26 20:34:05 PDT 2009


Jarrett Billingsley wrote:
> On Sat, Sep 26, 2009 at 11:23 PM, Jeremie Pelletier <jeremiep at gmail.com> wrote:
> 
>> There is no such thing as "not being able to happen" :)
>>
>> Object thisCannotPossiblyBeNullInAnyWayWhatsoever = cast(Object)null;
>>
>> I seem to be the only one who sees Walter's side of things in this thread
>> :o)
> 
> Why the hell would the compiler allow that to begin with? Why bother
> implementing nonnull references only to allow the entire system to be
> broken?

Because D is a practical language that let the programmer do whatever he 
wants, even shoot his own foot if he wants to. Doing so just isn't as 
implicit as in C.

Walter understands there are some cases where you want to override the 
type system, that's why casts are in D, too many optimizations rely on it.



More information about the Digitalmars-d mailing list