-
Notifications
You must be signed in to change notification settings - Fork 395
Support Generator
s, function*
, and yield
#5079
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
No it wouldn't. That means it's nothing that a Scala macro couldn't do with local transformations. There is no need to have dedicated language support for that. If generators had brought a unique superpower like coroutining, we would have added support for them years ago, already in the 0.6.x era. Related: #5064 |
@sjrd do you have any feel for whether generator chaining is optimized by VMs? (e.g. |
Generators and Anyway, good question. For |
Thanks for the reply :)
Yes, that is correct. So while it is not possible to implement stackful coroutines, it is possible to implement stackless coroutines using
I didn't realize that this is something that could be implemented with a macro instead of a compiler plugin. In any case, I also wondered if there would be a performance advantage to preferring |
Here is a recent document about the implementation of generators in V8. https://docs.google.com/document/d/1-iFoVuvpIEjA9dtSsOjmKL5vAzzvf0cKI6f4zaObiV8/ Edit with my thoughts:
|
Would fix scala-js#5079. * `async/await` works on JS and Wasm. The latter uses the JSPI proposal. * `function*/yield` only works on JS. * `yield_*` should work (on JS) but is untested. * `async function*` has theoretical support in the linker, but no support in the compiler backend for now.
Proof of concept: #5082. Feel free to try it out. If you can get some benchmarks with measurable improvements, that would give a good case to push this further. |
Would fix scala-js#5079. * `async/await` works on JS and Wasm. The latter uses the JSPI proposal. * `function*/yield` only works on JS. * `yield_*` should work (on JS) but is untested. * `async function*` has theoretical support in the linker, but no support in the compiler backend for now.
Would fix scala-js#5079. * `async/await` works on JS and Wasm. The latter uses the JSPI proposal. * `function*/yield` only works on JS. * `yield_*` should work (on JS) but is untested. * `async function*` has theoretical support in the linker, but no support in the compiler backend for now.
Would fix scala-js#5079. * `async/await` works on JS and Wasm. The latter uses the JSPI proposal. * `function*/yield` only works on JS. * `yield_*` should work (on JS) but is untested. * `async function*` has theoretical support in the linker, but no support in the compiler backend for now.
Would fix scala-js#5079. * `async/await` works on JS and Wasm. The latter uses the JSPI proposal. * `function*/yield` only works on JS. * `yield_*` should work (on JS) but is untested. * `async function*` has theoretical support in the linker, but no support in the compiler backend for now.
Would fix scala-js#5079. * Only only works on JS; not on Wasm. * `yield_*` should work (on JS) but is untested. * `async function*` has theoretical support in the linker, but no support in the compiler backend for now.
Would fix scala-js#5079. * Only only works on JS; not on Wasm. * `yield_*` should work (on JS) but is untested. * `async function*` has theoretical support in the linker, but no support in the compiler backend for now.
Would fix scala-js#5079. * Only only works on JS; not on Wasm. * `yield_*` should work (on JS) but is untested. * `async function*` has theoretical support in the linker, but no support in the compiler backend for now.
Would fix scala-js#5079. * Only only works on JS; not on Wasm. * `yield_*` should work (on JS) but is untested. * `async function*` has theoretical support in the linker, but no support in the compiler backend for now.
Would fix scala-js#5079. * Only works on JS; not on Wasm. * `yield_*` should work (on JS) but is untested. * `async function*` has theoretical support in the linker, but no support in the compiler backend for now.
I think this would enable suspension and thus implementation of coroutines directly in Scala.js (i.e. without needing a monadic datatype and a runtime interpreter of said datatype).
The text was updated successfully, but these errors were encountered: