3 ms·
The problem here isn't checked exceptions as such, it's that they are not first-class, so you can't write generic code in terms like "I take F and throw all E t
by int_19h 2y ago
The problem here isn't checked exceptions as such, it's that they are not first-class, so you can't write generic code in terms like "I take F and throw all E that F throws plus X".
Back when Java was adding lambdas, one of the competing proposals actually tried to fill that gap by having generic exception specification parameters: https://tronicek.blogspot.com/2007/12/exceptions.html https://tronicek.blogspot.com/2007/12/exceptions.html:
static <throws E> void performTwice({ => void throws E } block) throws E {
block.invoke();
block.invoke();
}
Alas, it was not to be.