Non-null objects, the Null Object pattern, and T.init

Adam D. Ruppe destructionator at gmail.com
Fri Jan 17 16:21:38 PST 2014


On Saturday, 18 January 2014 at 00:12:16 UTC, Andrei Alexandrescu 
wrote:
> Yes, improving the language is in the cards. I have collected 
> enough hard evidence to convince myself that null references 
> are a real and important issue (previously I'd agreed with 
> Walter who is considering it not particularly remarkable).

Have they tried using a NotNull!T yet? I wrote one ages ago for a 
phobos pull request that didn't really go anywhere, but I'm still 
keeping my file updated with new ideas (most recently, the 
if(auto nn = x.checkNull) {} thing):

http://arsdnet.net/dcode/notnull.d


I really think that is very close to meeting all the requirements 
here, but tbh I don't use it much in the real world myself so I 
could be missing a major flaw.

Of course, such library solutions don't change the default 
nullability of references.


More information about the Digitalmars-d mailing list