[Re-Proposal] Type only Unions

I read through the thread @xwu linked to a couple days ago, and I’m still not sure why sum-types-lite (that is, anonymous discriminated unions) are still considered off the table.

We still have tuples even though structs are usually favored. In fact, thanks to variadic generics, @Slava_Pestov has proposed making tuples conform to a new Tuple protocol, increasing their utility. Tuples have proven to fill a specific niche, where structural typing and inline definition are desirable. This seems to be particularly the case for arithmetic methods that report overflow. Are we certain that there is not a similar niche for structurally typed, anonymous, inline-defined enumerations? For example, what about Regex capture groups?

5 Likes