3 ms·
You could have checked exceptions with more flexibility than Java had, and it might work out well (or might break down for other reasons). "How do you write a
by dllthomas 11y ago
You could have checked exceptions with more flexibility than Java had, and it might work out well (or might break down for other reasons).
"How do you write a 'map' function that can accept a callback, where the callback may want to communicate back one of several distinct kinds of error?"
With Java style checked exceptions, you don't, and that's for sure a problem.
However, one approach would be to say that map is polymorphic in the exceptions that may be raised from within it. But that set is not entirely unbounded - it is precisely the set that can be raised by its function argument, unioned with any that might be raised during traversal of its container argument.