Blocking await!

The issue with reasync is a lot less complicated: async functions are called differently than synchronous functions. rethrows works because throwing functions put the error in an extra register reserved for this purpose by Swift that is ignored by non-throwing functions. Since async functions have to be able to suspend, my understanding is that they are called a little bit like classic completion-handler functions (where you provide a function to run once the async work finishes). This means that a function written as reasync would need to have its code emitted twice (once for sync, once for async). That’s definitely something the compiler could do in theory, but nobody has implemented and pitched it yet.

3 Likes