sumtypes for D
deadalnix
deadalnix at gmail.com
Tue Nov 29 02:33:21 UTC 2022
On Tuesday, 29 November 2022 at 00:48:32 UTC, max haughton wrote:
> Built-in sumtypes will unify a lot of codebases if done right:
> Tuples and sumtypes are to writing beautiful programs what the
> container issues are to writing beautiful libraries IMO.
>
Unifying and yada yada are all very nice sounding words, but I'm
afraid this is not very actionable.
Here is the deal. We can agree that this is useful. Great. Now
step back and look at the larger picture.
The number of people who would use D if we changed nothing to the
current thing but sum type is exactly 0. Maybe 1 if stars align
properly.
In the same way traction control is a great feature to have on
you car, but none of this matter when the passenger door cannot
close. And the passenger door is not closing right now.
This forum is full of problem that actual people have trying to
write actual D code. See
https://forum.dlang.org/thread/nzlnwbcezwyopjfiasan@forum.dlang.org for instance from just today.
A grand total of none of these problems people are facing would
be addressed by sum types. Not even one, kind of, if you are
squinting hard enough while blind drunk.
In fact, this is especially funny because I have spent the last
several day implementing what effectively amount to a sum type in
D. While having a syntax to express sum type would have been
nice, I don't doubt that, nothing on that front is a blocker.
What's a blocker is that some of types packed in the sum are
collection and I can't get them to behave right, because the way
I need them to behave like builtin slice, but I cannot.
I'm literally building a sum type, and I'm telling, NO amount of
integration of sum type into the language would change anything
about the practical problem I'm facing working on this, it would
just enable less boilerplate in part of the code that have no
problems.
Certainly, less boilerplate is good, but I'm trying to get shit
done. Boilerplate is workable. Broken type system is not.
You guys need an intervention. I'm serious.
More information about the Digitalmars-d
mailing list