Introducing Nullable Reference Types in C#. Is there hope for D, too?

Nick Treleaven nick at geany.org
Wed Nov 29 17:45:20 UTC 2017


On Sunday, 19 November 2017 at 22:54:38 UTC, Walter Bright wrote:
>> I can't see the problem. You go from nullable to non-nullable 
>> by checking for null, and the other direction happens 
>> implicitly.
>
> Implicit conversions have their problems with overloading,

The C# implementation doesn't affect overloading:

"There is no semantic impact of the nullability annotations, 
other than the warnings. They don’t affect overload resolution or 
runtime behavior, and generate the same IL output code. They only 
affect type inference insofar as it passes them through and keeps 
track of them in order for the right warnings to occur on the 
other end."

> interactions with const, template argument deduction, 
> surprising edge cases, probably breaking a lot of Phobos, etc. 
> It's best not to layer on more of this stuff. Explicit casting 
> is a problem, too.

Maybe this can be mitigated by having the compiler just do the 
job of tracking null tests and making this information available 
to a NotNull user defined type.


More information about the Digitalmars-d mailing list