IssueRaiser

proposal: spec: add sum types / discriminated unions

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.

Posted by DemiMarie on Mar 5, 2017, 11:39 PM

Tags

Related issues

Raise real-world problems, find people facing the same issue, and discuss solutions.4,500 issues0 comments

github (Software)

proposal: spec: add sum types / discriminated unions

DemiMarieMar 5, 2017, 11:39 PM

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.

Comments (0)

No comments yet. Start the discussion.

Comment on this issue