Disallow null references in safe code?
deadalnix
deadalnix at gmail.com
Tue Feb 4 10:26:08 PST 2014
On Tuesday, 4 February 2014 at 14:54:35 UTC, Adam D. Ruppe wrote:
> This gives us:
>
> * Implementation help - no binary cost for Nullable!Object
> since it just uses null directly instead of a bool isNull field
> (the optimizer also knows this)
>
static if(isReferenceType!T) {
union {
T t;
typeof(null) __;
}
}
> * Consistency with all other types. Nullable!int works,
> Nullable!Object can be passed to a template, inspected, etc.
> without new traits for isNullable and everything.
>
I'm not sure I understand that.
> * Library functionality so we can also make other types that do
> the same kind of thing
>
I'm really confused now. What are you defending ??
> Then, if we did the Type? syntax, it would just be rewritten
> into Nullable!Type. Nullable's definition would probably be in
> the auto-imported object.d so it always works.
??????
More information about the Digitalmars-d
mailing list