Better HN
topnewbestaskshowjobs
Log inSign up

sc22

3 karma · joined Nov 25, 2023 (3y ago) · 2 submissions

Submissions

comment 2y ago · link · parent

You _can_ write in Java that very interface you claimed could not be written.

   interface ThrowingRunnable<E extends Throwable> {
     void run() throws E;
   }
Only, hardly anybody writes it that way, so people forget that it's possible. Why don't people use exception polymorphism in that way? I am not sure, but I believe it would make code too verbose, since every function containing a virtual method call to something that might throw would have to be parameterized that way.

comment 3y ago · link · parent

Scala 3 has enums, which can also serve as ADts: https://docs.scala-lang.org/scala3/reference/enums/enums.htm...