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

I mean, sure, why are we calling it "Rust-style"; it comes from ML and its descendants and Rust is obviously very influenced by them. When I say "modern" I really mean... finally learned from what "we" were "all" reading about on Lambda The Ultimate 20 years ago about languages designed 40 years ago that were not part of the mainstream until about 5-10 years ago :-)

AFAIK TypeScript doesn't have ML-style pattern matching, but its type system is fairly expressive and you can do something "like" it https://dev.to/gvergnaud/bringing-pattern-matching-to-typesc...



I used "Rust-style enums" because if I just say "enum" then people think I mean something else. ;) And then I added the clarification to make sure nobody thinks I would claim that Rust invented Rust-style enums.

If I just say "algebraic data types" or "sum types" I fear many people won't know what I mean...


I think "discriminated union" is a useful bridge term here, even if it does confuse C programmers due to the conflated meanings of both enum and union in that language. It better represents the concept at an implementation level, and maps it to the C structure that enums more closely resemble in practice.




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

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

Search: