null [re: spec#]

Jonathan M Davis jmdavisProg at gmx.com
Sun Nov 7 04:55:04 PST 2010


On Sunday 07 November 2010 04:20:10 foobar wrote:
> Both the current D way and the C# way are ugly hacks.
> Ideally you should have TWO types: T and Option!T (ignore syntax for now).
> 
> Most of the time you would use:
> auto variable = new T(params);  // no need for nulls here!
> and for the situations where you actually NEED to have a non-initialized
> variable you'd use: Option!T variable; // look ma, explicitly asking for a
> nullable variable
> 
> Simple, ain't it? And it supports Walter's convoluted examples AND is
> explicit about it so it prevents illegal operations at compile time.

Making non-nullable the default would be a seriously breaking change and 
obviously contradict TDPL. So, I don't see that ever changing. Adding non-
nullable support to the language could be done - it's likely to be an additive 
change and wouldn't break any code - but making them the default? Not going to 
happen. _Maybe_ if D3 ever materializes, it could happen then, but it would 
break a lot of code.

- Jonathan M Davis


More information about the Digitalmars-d mailing list