Proposing std.typecons : Optional (with PR)
FeepingCreature
feepingcreature at gmail.com
Tue Jun 11 10:01:18 UTC 2019
On Tuesday, 11 June 2019 at 09:58:48 UTC, aliak wrote:
> If we're going to put an optional type there, I would consider
> not copy pasting nullable as it has some other issues as well,
> and maybe nail the interface down properly? E.g. having an
> optional that's a range would be rather awesome. Have you
> looked at: https://code.dlang.org/packages/optional. It has a
> lot of other added features as well but those can be removed if
> they're too much.
I've looked at that and I specifically disagree with the decision
to make it a range; that's why I didn't just internally switch to
dub optional. Ranges are not monads. We may wish we had a concept
of monads but we don't; ranges are not a general replacement for
any conceivable container. `Optional.front` is just *weird* and
unintuitive at first glance. It's not a bad decision in
isolation, but it doesn't fit what I consider "the D style" of
type design.
Sorry if that explanation is too fuzzy.
More information about the Digitalmars-d
mailing list