References in D
Timon Gehr
timon.gehr at gmx.ch
Wed Oct 3 14:46:57 PDT 2012
On 10/03/2012 06:59 PM, Maxim Fomin wrote:
> 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"?
>
Most of it, and fixing it up quickly may require adding explicit
assertions together with the question marks.
> 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.
'non-null reference' is an abominable term. It shouldn't have 'null' in
it. I'd just call it a 'reference'. Having a reference type whose
values always refer to an object, while allowing dereferencing
nullable-by-default references at the same time is not worth the effort.
Imho, either break all code or leave it out.
More information about the Digitalmars-d
mailing list