3 ms·
There are proposals to add enums to Go [1]. Enums are specific instance of sum types (aka discriminated unions), and while having simple typed enums would be ni
by atombender 8y ago
There are proposals to add enums to Go [1]. Enums are specific instance of sum types (aka discriminated unions), and while having simple typed enums would be nice, Go would benefit, in my opinion, from having true sum types, and this has also been proposed [2].
Unfortunately, due to Go's current semantics (e.g. zero values) and memory layout, adding sum types is not as straightforward as one might hope [3]. However, given that Go2 is allowed to break backwards compatibility, something might come out of the discussion.
[1] https://github.com/golang/go/issues/19814 https://github.com/golang/go/issues/19814
[2] https://github.com/golang/go/issues/19412 https://github.com/golang/go/issues/19412
[3] https://www.reddit.com/r/golang/comments/46bd5h/ama_we_are_the_go_contributors_ask_us_anything/d03t6ji/?st=ixp2gf04&sh=7d6920db https://www.reddit.com/r/golang/comments/46bd5h/ama_we_are_t...
- deleted 8y ago[deleted]