Proposing std.typecons : Optional (with PR)
FeepingCreature
feepingcreature at gmail.com
Tue Jun 11 13:55:52 UTC 2019
On Tuesday, 11 June 2019 at 12:30:10 UTC, aliak wrote:
> Your argument against it being a range sounds a bit too
> philosophical. I think we should consider the actual technical
> advantages/disadvantages of having it as a range or not. And if
> not, at least getting functions like map/flatmap/each/whatever
> as usable with optional.
>
We have "map for Optional/Nullable", that's `apply`.
> I basically think a bit of thought should be put in to putting
> an optional type in the standard library instead of copying
> nullable (as mentioned, the range thing is not the only problem
> - another big one is treating null as a valid value for
> classes).
That's a fundamental problem with D though. Null *is* a valid
value for classes. Making a class type optional just means that
you're adding *another* type that also means "absent" at a
different level of abstraction.
Was it the right decision to allow null in class types? Who
knows. (No.) But I don't think that's a decision that should be
patched in library types.
More information about the Digitalmars-d
mailing list