On Wed, Feb 25, 2015 at 2:39 PM, Bergi <[email protected]> wrote: > Axel Rauschmayer schrieb: > > OK. I see the use case for `throw()` (e.g. to convert a promise rejection >> into an exception when using generators for async). The only use case for >> `return()` is closing an iterator, then(?) >> > > If you are using generators for async, then you'd call `return()` when > your result promise is cancelled.
That seems a bit surprising to me -- I'd expect a cancelled promise to result in some kind of exception being thrown into my coroutine-style generator, not for execution to silently return out of the generator entirely. IIUC calling `return` on a coroutine would be analogous to a TCP-preserving control flow construct. While this could prove useful in the future, it doesn't really line up with anything in the language as is, so for POLA's sake, coro runners should probably stick to `next` and `throw`. That said, perhaps it's worth contemplating other control flow constructs to be invoked at the yield site, like break and continue (with label as the argument)?
_______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

