Michael Long
Jun 25, 2024

--

Dumb. Async functions require overhead over and above that of "normal" functions.

Further, marking functions as async tells the caller that this function may take some time, and you probably don't want to sit around on the main loop waiting for it to complete.

Doing 'go foo()' is basically the same as saying await foo.... and that could in fact "wrap" a normal function somehow.

But that just kicked the can down the road, since whoever called the function with go foo() now has no indication that they may be sitting there spinning their wheels. And so on.

So yes, functions that aren't guaranteed to return their results immediately are marked as such. And kicking off such a sequence must occur in an isolated, suspendible context (task).

--

--

Michael Long
Michael Long

Written by Michael Long

I write about Apple, Swift, and SwiftUI in particular, and technology in general. I'm also a Lead iOS Engineer at InRhythm, a modern digital consulting firm.

Responses (2)