TSPL Pitch: Typed throws

Looking good, still excited to see this coming to the language A couple of points:

  • Is it worth mentioning that a function that throws Never is equivalent to a non-throwing function? i.e func f() throws(Never) -> T is equivalent to func f() -> T. Perhaps an example of why this is useful, and how rethrows can be achieved with type throws (and is possibly preferred)?
  • Is it worth labouring a bit more that regular throws is still preferred, and that package authors should still keep the surface area of their APIs as small as possible for the greatest flexibility. i.e. avoid encoding (nesting) the concrete errors of their dependencies in their own errors if possible. At one point or another, abuse of typed throws was a big concern:

Emphasis added. This was a while back now, so maybe in the light of day those concerns have softened somewhat.

3 Likes