-
Notifications
You must be signed in to change notification settings - Fork 109
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
Why can tasks (or streams) throw(), but not return()? #7
Comments
This asymmetry has been bothering me as well, but I have been asking myself the opposite question, what does it mean for the consumer to return? Perhaps that question can be answered if I study what it means for generators now. I am skeptical if it means that the yield behaves like a return. |
Well, from what I can tell, (sync) generators are a complete free-for-all in terms of capabilities vended; the consumer can do the exact same set of operations that the producer can, just using methods instead of syntax. |
Yeah, sync and async generator objects should probably be symmetric, and they would be completely symmetric if we renamed "next" to "yield" (not going to happen, but perhaps for the purposes of a completely ivory tower blog…) |
I added |
WRT your question, I don't really know yet what |
Synchronous generators, per a couple TC39 meetings ago, can return() in addition to throw()ing. Why can't tasks, or streams? It says "the observer may unsubscribe with an error" for a task's throw(); why can't they unsubscribe without an error?
The text was updated successfully, but these errors were encountered: