Null references redux

downs default_357-line at yahoo.de
Sun Sep 27 04:08:26 PDT 2009


Jeremie Pelletier wrote:
> 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.

Sure, but if you set out to break it the compiler really can't (or shouldn't) help you. This whole debate, as far as I know, is about defaults, i.e. preventing *unintentional* nulls.



More information about the Digitalmars-d mailing list