Nullable types

Mehrdad wfunction at hotmail.com
Wed Jun 20 10:49:13 PDT 2012


On Wednesday, 20 June 2012 at 17:43:27 UTC, Mehrdad wrote:
> I thought I mentioned?
>
> 1. It uses typeof(null) to _actually_ integrate with _null_, 
> instead of making up methods like nullify(), get(), etc.
>
> 2. It tries to do what C# does. (opEquals, opCmp, etc.)


In case that wasn't clear...

1. You can't pass Phobos's Nullable type to something and expect 
"foo = null;" to work... even though it's supposed to be 
"nullable". The interface is pretty wacky. (opAssign, opCmp, 
opEquals)

2. It doesn't properly handle the comparison of e.g. 
Nullable!bool (or anything else for that matter).

3. It uses .clear(_value), which I believe is unnecessary. Just 
_value = T.init should be enough.

etc.


Also, side point:

I don't understand the point of Nullable(T, T nullValue) or 
NullableRef(T)... are they /actually/ useful? Or were they just 
there to span the entire vector space, so to speak? :P


More information about the Digitalmars-d mailing list