6 ms·
> If python was able to reliably tell you possible exceptions I know typed errors in Java are regarded by many as a failure... but it is still conceptually ver
by hamandcheese 3y ago
> If python was able to reliably tell you possible exceptions
I know typed errors in Java are regarded by many as a failure... but it is still conceptually very appealing to me.
I love result types and pattern matching in more typed/functional languages, except that they often have similar issues to go re: not having a stack trace.
- erik_seaberg 3y agoI liked checked exceptions, but higher-order functions break them. The method signature of stream.map(f) allows a generic type for f but it can't vary with f's exceptions. The choices usually boil down to "only throw unchecked exceptions" (like Runnable) or "throw any exception" (like Callable).
- plorkyeran 3y agoIt’s worth noting that this is specifically a shortcoming of Java’s type system and not an unsolvable problem. I’m a fan of Swift’s solution where you can directly mark a function as only rethrowing errors from a given parameter; it’s a lot simpler than making the error type a full fledged type parameter and covers most scenarios.