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

> Enums are super nice, but it's very annoying that you cannot just use the value as a type. My project had a lot of enums (user-provided query trees), and it was causing a lot of friction.

Note that OCaml has this feature of using-a-enum-value-as-a-type (or using a subset of enum values as a type, etc.). It works very well, but it quickly produces impossibly complicated error messages.

I'd like Rust to have this feature, eventually, but not before there is a good story for error messages.



I am not very familiar with OCaml, but why would such a feature result in complicated error messages? I can only really imagine two new error scenarios: "Expected Enum::ValueA, got Enum" and "Expected Enum::ValueA, got Enum::ValueB".


I’m interested in this feature because of the ”incremental” static case analysis it enables. What’s the problem with the error messages?




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

Search: