3 ms·
> If you have a non-async function that you want to change to be async, or the other way around, then you have to change every single call site. At least in th
by chronial 9y ago
> If you have a non-async function that you want to change to be async, or the other way around, then you have to change every single call site.
At least in the direction non-async -> async, that is clearly a good thing, since you are changing semantics a lot.
This code is always safe:
x = globalObject.a
functionWithoutSideEffects()
gobalObject.a = x + 1
While this is not:
x = globalObject.a
await functionWithoutSideEffects()
gobalObject.a = x + 1
> It's way too easy to forget to add "await" to an async call, and doing so leads to failures that can be hard to track down.
This a situation that could clearly be improved with better detection of these cases. Or maybe it should be completely illegal to call an async function without a keyword, so you have to do either `await func()` or `promise func()`.