References in D

Henning Pohl henning at still-hidden.de
Sat Sep 15 11:24:52 PDT 2012


On Saturday, 15 September 2012 at 18:05:55 UTC, Jonathan M Davis 
wrote:
> I'd argue that using null for indicating something other than 
> the lack of a
> value is bad design. But there are plenty of cases where being 
> able to
> indicate that there is no value is useful.
I agree.

> And if a function requires that a
> pointer or reference or array or whatever have a value, then 
> there's always
> DbC or exceptions.
So why not clear this up at compile time if possible? Then you 
can also easily distinguish between "really there" and "maybe 
there" objects by passing either a reference or a pointer.

> Just because someone can misuse a feature  doesn't mean that
> a feature shouldn't be there.
Why not set the "non-nullable references", which cannot be 
misused, as default and still enable the "nullable references" 
feature as optional by passing a pointer.


More information about the Digitalmars-d mailing list