First Draft: Nominal Sum Types via `enum union` and `switch` Expressions
Dennis
dkorpel at gmail.com
Tue Sep 15 13:07:30 UTC 2026
On Monday, 14 September 2026 at 06:35:13 UTC, Meta wrote:
> ## Rationale
>
> (...)
>
> Library solutions like `std.sumtype` implement tagged unions
> via complex template metaprogramming. However, library
> implementations suffer from slow compilation throughput, opaque
> diagnostic errors, ...
Considering std.sumtype and your implementation both exist, can
you give comparisons showcasing improved compile times and error
messages?
> ... and the inability to exploit compiler memory layout
> optimizations such as niche optimization.
If this is core rationale, why is "Niche Optimization" not
implemented, and why couldn't a library sumtype do Niche
Optimization? I feel like currently the opposite is true: library
sum types are free to lay out the fields however they want, while
this DIP's "In-Memory Layout" section bakes a strict layout
scheme into the language.
More information about the dip.development
mailing list