News for hackers. Stuff that matters.
Re:Software development topics I've changed my mind on after... by lmm on Wednesday February 05, 2025 @09:56AM (#42949296)
You can't be polymorphic between not throwing and throwing, or between throwing different numbers of exceptions. You have to write something like:

    <R> List<R> map(Function<? super T,? extends R> mapper) { ... }
    <R, E1 extends Throwable> List<R> map(FunctionThrows1<? super T,? extends R, E1> mapper) throws E1 { ... }
    <R, E1 extends Throwable, E2 extends Throwable> List<R> map(FunctionThrows2<? super T,? extends R, E1, E2> mapper) throws E1, E2 { ... }
and so on until you get bored.
Re:Software development topics I've changed my mind on after... by catlifeonmars on Wednesday February 05, 2025 @10:07AM (#42949471)
Ah because there is no way to express E1 | E2 as a type parameter?
Re:Software development topics I've changed my mind on after... by lmm on Wednesday February 05, 2025 @08:19PM (#42957772)
Yeah. Ironically the JLS includes a complete specification of what the type E1|E2 is, because if you write a catch block that catches both then that's the type of what you catch, there's just no syntax for it.
Re:Software development topics I've changed my mind on after... by dustingetz on Wednesday February 05, 2025 @11:41AM (#42951118)
ah!