References in D

Jonathan M Davis jmdavisProg at gmx.com
Sun Sep 16 17:23:24 PDT 2012


On Monday, September 17, 2012 00:43:50 deadalnix wrote:
> It shouldn't be that hard to create a Nullable!T template.

We have one, and it would be wasteful to use that for references or pointers 
when they're naturally nullable (though you're more or less forced to if you 
want a truly nullable array thanks to the nonsense that empty arrays and null 
arrays are considered equal). You're forced to have a separate boolean value 
indicating whether it's null or not. That might make sense for an int, since 
it can't be null, but pointers and references _can_ be and are in every type 
system that I've ever used.

Regardless, the solution at this point is going to be to add 
std.typecons.NonNullable. It would be in there already, but the pull request 
with it needed more work, and it hasn't been resubmitted yet.

- Jonathan M Davis


More information about the Digitalmars-d mailing list