Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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-195c73...



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?


Yes, pattern matching (with destructuring) would be a small addition to the language, and it would be awesome, even without sum types


Python 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?




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: