Feedback Thread: DIP 1034--Add a Bottom Type (reboot)--Community Review Round 1
Piotr Mitana
the.mail.of.mi2 at gmail.com
Sat May 16 16:04:25 UTC 2020
One more thing to possibly even strengthen the rationale: bottom
type will play nicely with Nullable, which would be a minor yet
practical added value.
Let's have the struct:
struct S
{
Nullable!int field1;
int field2;
}
If we want to pass a null to field1 and a value to field2, we
construct it with
S(Nullable!int.init, 4);
We need to state the underlying type explicitely. Bottom type
would allow us to use
S(Nullable!noreturn.init, 4);
BTW,
S(Nullable!nothing.init, 4);
would look a bit better.
Furthermore, in std.typecons there could be defined a generic
value:
auto null_ = Nullable!nothing.init;
In this case we could simply write:
S(null_, 4);
More information about the Digitalmars-d
mailing list