Steven Schveighoffer wrote: > Sure, do whatever you want for your *private data members*. I see too > much value in Optional!T being aliased to the underlying T to go for the > completely generic solution which requires special syntax to get at the T.
And I see no value at all, but a lot of danger. Even ignoring, what about this: void f(ref int v) { // Do something... } void g() { Optional!int x = 5; f(x); } Or this: void report_error(int); void f(T)(out T v) { if (error_condition) throw new SomeException(); v = something; } void g() { Optional!int v = someCalculation(); if (!isNull(v)) { try { f(v); } catch (SomeException) { report_error(v); // Oops, invalid: 'v' turned into null. } } } Note how in the second example, the semantics of the function 'f' subtly change depending on whether the argument is an 'int' or and 'Optional!int'. Proxies, especially proxies that add functionality to their base type, cannot act exactly like the type they are proxying. Using a proxy therefore requires the significant mental overhead of keeping track of all the corner cases in which the proxy does not act like the type it is proxying, as well as the hassle of working around those limitation whenever they come up. -- Rainer Deyke - rain...@eldwood.com