On Friday, 24 May 2013 at 14:03:24 UTC, bearophile wrote:
Max Samukha:
The question is what should be the result of:
Nullable(int*)?
Nullable!(Nullable!T)?
Forbidden (like in C#)? Aliased to the source type? A distinct
type?
In D Nullable!(int*) needs to be a different type, because the
interface is different between a pointer and a Nullable.
It could be normalized by free functions isNull(T)(T t),
nullableValue(T)(..) etc. Isn't that what was done to arrays so
they could support the range interface?
But often you want to use something like Nullable(int*, null)
or Nullable(int*, cast(int*)null) instead.
Do you have an example? In what cases is the distinction between
a null null int* and non-null null int* necessary?
In the second case maybe it can be collapsed into a single
Nullable, but such behavior needs to be documented.
Ok.
Bye,
bearophile