3 ms·
To make adts / sum types useful you really need pattern matching with destructuring, which Go appears to lack https://kranfix.medium.com/pattern-matching-in-go
by nextaccountic 4y ago
To make adts / sum types useful you really need pattern matching with destructuring, which Go appears to lack
https://kranfix.medium.com/pattern-matching-in-golang-195c7321a7f2 https://kranfix.medium.com/pattern-matching-in-golang-195c73...
- eru 4y agoYou can use sum types without pattern matching and vice versa, but you are absolutely right that they synergies well. I don't know enough about Golang: do you know whether it's possible to add pattern matching with destructuring as a fairly shallow syntactic sugar? Generics were a much bigger change to the underlying language (and so would be Rust-like lifetimes, or even immutability); but pattern matching seems like something that should be relatively easy to add with only local repercussions?
- nextaccountic 4y agoYes, pattern matching (with destructuring) would be a small addition to the language, and it would be awesome, even without sum types
- eru 4y agoPython had that kind of pattern matching for ages, but only recently got pattern matching on something like sum-types. I only found that previous kind of pattern matching useful occasionally. But I guess I would miss it a lot, if it was gone?