News for hackers. Stuff that matters.
Re:A new approach to error handling by mrkeen on Tuesday July 30, 2024 @05:51PM (#41114488)
> What instance of polymorphism does it lack?

1) Higher-kinded. List<Integer> is OK and List<T> is OK, but T<Integer> is not.

2) Dispatch to the right method based on param types. If your class exposes foo(Apple) and foo(Banana), it will not route a Fruit to either of those methods even if it is one of those specific types.

3) Return type polymorphism, which is probably the most relevant to the error-handling discussion, e.g. in this example:

  fn greet() {
    fail "not greeting today"
  }
in another language, fail could be polymorphic over its return type - that is, if called from a function returning an Optional<>, fail itself could choose to return Optional.empty(). Or it could return the failed version of a CompletableFuture<>, or even throw a runtime exception depending on how the language was implemented.

There are no comments on this comment yet.