Generator return() and exceptions

Allen Wirfs-Brock allen at wirfs-brock.com
Thu Jul 24 10:45:32 PDT 2014


On Jul 24, 2014, at 10:38 AM, Nathan Wall wrote:

> Allen Wirfs-Brock wrote:
> > So going back to my original questions.  Given that we now have return()
> > available to close an abnormally discarded generator, when would somebody
> > (presumably implementing a control abstraction) actually want to apply
> > throw() rather than return() to an iterator?
> 
> Sorry, I may be misunderstanding, but what about the use from Task.js?
> 
> https://github.com/mozilla/task.js/blob/master/lib/task.js#L395
> 
> The above should log "from foo".  Wouldn't `throw()` be needed for that?

Right, that's the use case I was lookingor.  Also mentioned by Jeremy in an earlier response.

Allen

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20140724/6b81ea90/attachment.html>


More information about the es-discuss mailing list