Le 17/09/2012 02:23, Jonathan M Davis a écrit :
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.
And this have proven to be an important source of problem in mostly all
languages.
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.
I don't think this is implementable as a lib in a satisfying way.