References in D

Maxim Fomin maxim at maxim-fomin.ru
Wed Oct 3 09:59:00 PDT 2012


On Wednesday, 3 October 2012 at 16:36:15 UTC, Henning Pohl wrote:
> Just put something like a questionmark behind the reference 
> type to indicate that it's nullable.
...
> Not really. It's all about one question mark for example.

How much code would be broken by moving nullable references from 
current state to "question mark notation"?

I expect that non-nullable class objects (called references here) 
addition (if there is no objections to idea in general) would not 
break much code and would not request vast syntax changes. And it 
likely can be done by still defaulting to nullable references. 
For example, it can be done with the help of @nonnullable (like 
immutable) type qualifier and semantic check of operations 
involving references with such qualifier. Anyway, my estimation 
of probability of accepting constructions like "type&", "type*?", 
etc and defaulting to non-null references is very low, at least 
for D2.


More information about the Digitalmars-d mailing list