Current sentiment on Nullable.get
Sebastiaan Koppe
mail at skoppe.eu
Thu Dec 13 12:22:35 UTC 2018
On Tuesday, 11 December 2018 at 22:32:45 UTC, Jonathan M Davis
wrote:
> the property isNull became confusing to some folks, because
> they thought that the null value of a pointer and whether the
> Nullable itself was null were related, when they're not (and if
> they were, it would cause subtle bugs - especially in generic
> code).
Could you elaborate on some of those subtle bug? And are they
worse than the following?
---
import std.typecons;
class C {
}
void main() {
Nullable!C c;
assert(c.isNull);
c = null;
assert(!c.isNull);
}
---
What about having Nullable!T* decay into a wrapped pointer. Why
does it need to keep its own bool when that information can be
captured in the pointer?
Or is there some difference between a Nullable!T* with a null
value and one with no value? I thought no value and null to be
the same thing. But if it is, why is it called Nullable?
More information about the Digitalmars-d
mailing list