4 ms·
There are two issues with async/await annotations in most languages: - The annotation doesn't guarantee any particularly useful property: in many languages asy
by gpderetta 2y ago
There are two issues with async/await annotations in most languages:
- The annotation doesn't guarantee any particularly useful property: in many languages async functions can still block or take arbitrary time, while on the other hand non-async functions can still lead to reentrancy issues.
- Most languages do not allow abstracting over async functions: you end up having to write the same higher order function twice even if it would be agnostic over the effectfulness of its parameter.
Some languages, for example some of those with first class effects and no implicit side effects, you can both enforce the property and abstract over the effectfulness.
But for most languages the real reason the async annotations exists is because it is a way to syntactically enforce that only a single stack frame can be suspended as opposed to a whole stack, which is tradeoff between usability, and performance and space usage. The supposed benefit is a post-hoc rationalization.