3 ms·
You 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
by eru 4y ago
You 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?