Re:Why Checked Exceptions Failed
by crabbone on Sunday July 16, 2023 @04:38AM
(#36744828)
> Constrained generic parameters are actually super useful.
Then you missed the main point: if you require the generic function to accomodate all sorts of kinds of exceptions raised by the functions it may call, this requirements now propagates to every function it may call. So, you end up implementing functions with unnecessary "throws" because they might be used in a generic function which had to add that clause because of some other completely unrelated function.
Alternatively, you aren't writing generic code at all, you just write two implementations which happen to have similar names.
Then you missed the main point: if you require the generic function to accomodate all sorts of kinds of exceptions raised by the functions it may call, this requirements now propagates to every function it may call. So, you end up implementing functions with unnecessary "throws" because they might be used in a generic function which had to add that clause because of some other completely unrelated function.
Alternatively, you aren't writing generic code at all, you just write two implementations which happen to have similar names.