Earlier quoted context omitted.
My mind went to Java's checked exceptions -- not sure if anyone today believes that coloring is still a good idea.
The problem with checked exceptions afaik was far more in the execution than in the idea itself. And also late 90s-early 00s was different time in general.
fn someFn() -> Result
T someFn() throws E
fun someFn(): T | E // Kotlin's proposed error unions
Checked exceptions actually compose a little better when you have a function that can throw multiple types: T someFn() throws E, F, G
This is like a union type of E | F | G. I don't know about Rust, but most languages won't let you do that over generic types like Result.The main problem for Java's checked exceptions is just how boilerplatey they are, especially when you can't handle something. In Java if you need to become "unchecked" or panic you need to:
try {
someFn();
} catch (SomeException ex) {
throw new RuntimeException(ex); // dunno panic
}
Ideally that would just be: someFn()!!!!; // shut up compile panic if this happens