by pestaa · 14y ago · 0 comments
it’s possible to make sync function async
it’s not the case other way round
Is this terminology correct? I thought it is easier to make async functions sync by blocking it, and harder to unblock a sync one. Am I confusing this with something else?What the quoted bit boils down to is that any function that returns normally can be converted into a function that calls a callback, but not the other way around.
On the other hand, you need something like CPS or coroutines to cleanly use an async function in a program mostly using sync APIs.
Of course, if you have the right tools (CPS/coroutines) you can make any async API look sync, as you said.