3 ms·
Impossible due to how async is implemented (as generators).
by iikoolpp 7y ago
Impossible due to how async is implemented (as generators).
- pitaj 7y agoJS async is implemented as generators as well AFAIK
- dlbucci 7y agoNot unless promises are implemented with generators. I dunno though, I feel like there's some overlap between the two concepts, so maybe they are?
- pitaj 7y agoPromises are just objects which represent an asynchronous value. Async/await are coroutines: they have a shared context, stack, etc. They can be paused and resumed. The implementation of async/await depends on the engine, but I'm pretty sure they use the same generator backend. Babel and other transpilers convert async functions actual generator functions. By contrast, promises are a fairly simple runtime library.
- Scooty 7y agoI'm not sure how they're handled internally, but async functions are no longer generators. For a while after generators and before async/await, generators were used as a polyfill.
- pitaj 7y agoBecause of how similar they are, it would make sense to implement async/await using existing generator backends in the VM, right?