[Pitch N+1] Typed Throws

At risk of derailing the thread, one further benefit of reducing rethrows to syntactic sugar is the precedent it sets for enhancing other effects clauses:

For example, the idea of a reasync clause has already been raised as a counterpart to rethrows, but with the ideas surrounding typed throws it sheds some new light on what could potentially be achieved.

One of the big things that seems to be coming out of this proposal is just how useful having a generic 'handle' for an effect is when creating composable types like Sequence or AsyncSequence.

It crossed my mind that this might be useful for the async clause, too. Beyond whether something is just asynchronous or not, I've found myself occasionally frustrated that I haven't been able to 'thread through' the asynchronous execution context into third party modules.

However, if the async effects clause offered a generic handle, this becomes possible.

func a1()
// is equivalent to
func a2() async(Never)

func b1() async
// is equivalent to
func b2() async(any Actor)

@MainActor func c1() async
// is equivalent to
func c2() async(MainActor)
9 Likes