Proposing std.typecons : Optional (with PR)
FeepingCreature
feepingcreature at gmail.com
Tue Jun 11 07:46:38 UTC 2019
Since my rfc regarding deprecating `alias get this` in Nullable
(see https://github.com/dlang/phobos/pull/7060 ) encountered no
meaningful criticism (as I'm tactfully choosing to interpret the
total absence of reaction), but somebody mentioned that a new
type may have more success, since it doesn't have to justify
itself in the same way as a change to existing behavior, I
present `Optional`: https://github.com/dlang/phobos/pull/7065 .
To reiterate the difference:
`Nullable` is the standard type for "adding an undefined value
state to an existing type". It's being abused as an `Optional`
type. Why "abused"? Well:
1. `get` is **undefined** if Nullable is null
2. `get` is called implicitly.
This is not good behavior for an `Optional` type! Since my
attempt to turn `Nullable` into an `Optional` type encountered
zero enthusiasm and mild resistance, I've started a second
parallel attempt to introduce an `Optional` type from scratch.
(Translation: I've copypasted `Nullable` and changed a few names.)
Opinion? Anyone? Anyone at all? I'm so alone...
More information about the Digitalmars-d
mailing list