Rust already has most of what I want from error handling: explicit control flow, errors as values, and concise propagation with ?. The friction comes when deciding what to put in the error half of Result. We often end up choosing between precise types that require boilerplate and convenient types that hide which errors can occur. But precision and convenience do not have to be competing goals. Error types should compose as easily as the functions that return them.
So basically their argument is that the missing piece is anonymous sum types. I tend to agree! It would be amazing to have that as a language feature, i.e.
Result<(), FooError | BarError>. Unfortunately that is unlikely to arrive to the language for a loooong time… But I think I will definitely try out this library in the meantime.A language feature is not needed because macros exist.
I would even argue that perhaps the most important role macros play is blocking adding endless language features 😉
Macros are often not very ergonomical to use compared to language features.
Also, why anonymous product types but not anonymous sum types? It seems kind of weird to me. Anonymous sum types can be just as useful as anonymous product types, as the blog post illustrates quite well I think.
While I agree with you that anonymous sum types are useful, the language designers tend to avoid anything that might include a hidden cost (in this case either the size of the enum or cost of boxing). Something along those lines might end up in the language eventually, though.
The language wouldn’t have lost much without tuples actually. But they do at least have direct pattern destructuring utility. Anonymous enums don’t.
They also don’t pose potential future awkwardness if/when variant types become a thing.