Null references redux

Jason House jason.james.house at gmail.com
Sun Sep 27 08:31:39 PDT 2009


Lutger Wrote:

> This is what it's about, I think: are non-nullable references *by default* 
> so annoying as to cause programmers to initialize them with wrong values (or 
> circumventing them in other ways)? 
> The answer may depend on the details of the feature, quality of 
> implementation and on the habits of the 'programmers' in question, I don't 
> know. 

In reality, the issue becomes what will programmers do to bypass compiler errors. This is one area where syntactic sugar is worth its weight in gold. I'm envisioning the syntax of Fan, or a very C#-like syntax:

SomeType x; // Not nullable
SomeType? y; // Nullable

If the developer is too lazy to add the question mark and prefers to do
SomeType x = cast(SomeType) null;
Then it's their own fault when they get a runtime segfault to replace a compile-time error.   




More information about the Digitalmars-d mailing list