Nullable or Optional? Or something else?
Rainer Deyke
rainerd at eldwood.com
Thu Sep 3 13:20:41 PDT 2009
Steven Schveighoffer wrote:
> How does one distinguish an Optional!(Optional!int) that is null from an
> Optional!(Optional!int) whose Optional!int is null? If there's no way
> to test for it, then they are not conceivably different.
That's the fatal flaw in Andrei's design that I was pointing out, yes.
> I think Andrei is right here, for any type T that already is nullable
> (including pointer and reference types), Optional!T should alias to T.
Your conclusion is backwards here. In order for Optional!T to be
useful, it must be able to hold all possible of T plus a distinct null
value. If Optional!T cannot do that for T = Optional!T2, then
Optional!T is useless in generic programming, bordering on useless in
general. I think my example program demonstrated this amply.
--
Rainer Deyke - rainerd at eldwood.com
More information about the Digitalmars-d
mailing list