On Thu, 03 Sep 2009 16:20:41 -0400, Rainer Deyke <[email protected]> wrote:

Steven Schveighoffer wrote:
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.

I disagree, how many ways do you want to say something is unset? I think one case -- is this thing null -- is plenty for 99% of cases. Your case, well, I had trouble understanding it, but I think the nuance of how something is unset is not usually important.

I think that what you will find with a solution that *does* allow this, you will be sacrificing something else -- such as syntax clarity or a member function.

If you have specific requirements for "is this set to nulla or nullb," then I think that's a more complicated problem to solve, one which requires more complicated structures than what is being proposed here. I don't think we should cater a feature like this to the one time somebody needs 8 different names for snow...err null.

What I would *love* to see is a way to intercept these statements, and handle them specially:

x is null;
x = null;

That doesn't fit your problem at all, since there is only one keyword named null.

-Steve

Reply via email to