News for hackers. Stuff that matters.
Re:Go 1.27 by Splizard on Wednesday August 19, 2026 @04:01PM (#49366456)
Tagged unions can be implemented in user code, you dont actually need language support to use them.

https://github.com/splizard/tagged

Re:Go 1.27 by mirashii on Wednesday August 19, 2026 @04:11PM (#49366564)
This is only a small piece of the story for what people say when they want tagged unions. Without all of the ancillary support in the language, like exhaustive pattern matching, it really doesn't count.
Re:Go 1.27 by Splizard on Wednesday August 19, 2026 @04:30PM (#49366826)
You can also add support for exhaustive switches on tags.
Re:Go 1.27 by catlifeonmars on Thursday August 20, 2026 @03:01AM (#49371354)
Just as a linter config though?
Re:Go 1.27 by Splizard on Thursday August 20, 2026 @09:42PM (#49382647)
No, by leveraging unkeyed struct initializers as the switch case pattern, which the Go compiler does exhaustiveness checking on.
Re:Go 1.27 by shhsshs on Wednesday August 19, 2026 @04:26PM (#49366763)
That is a LOT of code (very ugly code, I would add) that could be replaced by `type Float = float32 | float64` in a language with actual support for union types.
Re:Go 1.27 by kccqzy on Wednesday August 19, 2026 @05:26PM (#49367425)
Tagged unions are not union types. A union type is a supertype for any arbitrary collection of types, but a tagged union aka sum type is a single type with multiple data constructors, and does not require subtyping to be implemented.
Re:Go 1.27 by kccqzy on Wednesday August 19, 2026 @05:25PM (#49367408)
The C++ committee said the same thing, and gave us std::variant. They are painful to work with and do not really deliver most of the benefits people want.