Fwd: Reason why generators do not have references to themselves?

Bradley Meck bradley.meck at gmail.com
Thu Jan 23 16:30:48 PST 2014


Is that true even though then should fire after the generator unwinds its
stack? I am using regenerator right now while playing with this stuff.
On Jan 23, 2014 5:43 PM, "Brendan Eich" <brendan at mozilla.com> wrote:

> Andrea Giammarchi wrote:
>
>> arguments.callee.caller would have done that </trolling>
>> </but-actually-not-so-much>
>>
>
> No, Bradley wants the generator-iterator (what ES6 draft calls a
> Generator), not the generator function (GeneratorFunction). Any .callee
> would have to be a function, so a GeneratorFunction.
>
> But the gist'ed example won't work:
>
>   function*  doLogin_()  {
>     try  {
>       /* START ASYNC TRANSPILE */
>       login(req).then(function  (session)  {
>         gen.next(session);
>
>
> You can't next an active generator.
>
> Instead, the trick is to avoid promises inside the generator function. Put
> them "on the outside" (and "backstage") as task.js does.
> http://taskjs.org/.
>
> /be
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20140123/168c2382/attachment-0001.html>


More information about the es-discuss mailing list