https://issues.dlang.org/show_bug.cgi?id=17440

--- Comment #12 from hst...@quickfur.ath.cx ---
I think you misunderstood my comment.  I meant that one way to fix this bug is
to change Nullable, or at least the overload that takes a single type
parameter, so that it does not instantiate for reference types, or redirects
the instantiation to Nullable!(T, null), so that when you call .nullify on it,
it will just set the reference to null instead of attempting to destroy the
object by calling .destroy on it.

It really does not make sense to use Nullable!T, as currently implemented, for
a class type T, since making that means there will be *two* null states, one
with .nullify / .isNull, and the other with `= null` and `is null`, and the two
null states will not be equivalent. That will only lead to more confusion.  The
fact that Nullable!T's dtor calls .destroy is further proof that the original
intent was to use it with by-value types, not with class references.  I'd say
either the docs should recommend using Nullable!(T, null) for class types T, or
else Nullable!T in that case should just internally redirect to Nullable!(T,
null).

--

Reply via email to