-
Notifications
You must be signed in to change notification settings - Fork 18.3k
Open
Labels
LanguageChangeSuggested changes to the Go languageSuggested changes to the Go languageLanguageChangeReviewDiscussed by language change review committeeDiscussed by language change review committeeProposal
Milestone
Description
This is a proposal for sum types, also known as discriminated unions. Sum types in Go should essentially act like interfaces, except that:
- they are value types, like structs
- the types contained in them are fixed at compile-time
Sum types can be matched with a switch statement. The compiler checks that all variants are matched. Inside the arms of the switch statement, the value can be used as if it is of the variant that was matched.
tarcieri, kron4eg, dmke, dadrian, nullchinchilla and 979 morecznic, 4ad, OneOfOne, JekaMas, danielchatfield and 30 moreccsnake, tema3210, venus-as-a-boy, Congee, valer-cara and 10 moreainar-g, Feuermurmel, emil14, schneiderfelipe, lenkite and 10 moretarcieri, kron4eg, hectorj, jabley, hooluupog and 204 moreainar-g, emil14, schneiderfelipe, dscafati, brpapa and 16 moreWLun001, kifirkin, diegobernardes, valer-cara, zweimach and 15 more
Metadata
Metadata
Assignees
Labels
LanguageChangeSuggested changes to the Go languageSuggested changes to the Go languageLanguageChangeReviewDiscussed by language change review committeeDiscussed by language change review committeeProposal