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

hst...@quickfur.ath.cx changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |hst...@quickfur.ath.cx

--- Comment #9 from hst...@quickfur.ath.cx ---
But by-reference objects in D *already* have nullable semantics, i.e.:

-------
class C {}
C c;
assert(c is null); // c is null by default
c = new C;
assert(c !is null);
c = null; // nullify
assert(c is null);
-------

Of course the syntax is slightly different (direct use of null vs. .isNull /
.nullify).  But there's really no benefit to using Nullable with reference
types in D.

OTOH, if you're using generic code that expect a single API for nullable
objects, perhaps the solution is to write an overload of Nullable that simply
maps .isNull to `is null` and .nullify to `= null` when the wrapped type is a
class.

--

Reply via email to