On Sunday, December 8, 2013, Hemanth H.M wrote: > Ah! Sweet :) > > Makes sense of why send() method was implemented for generators. >
send(value) was removed in favor of next(value) Rick > Can this be a pattern in itself or is there any specific name for this > paradigm ? > > > On Sun, Dec 8, 2013 at 3:11 PM, Brendan Eich > <[email protected]<javascript:_e({}, 'cvml', '[email protected]');> > > wrote: > >> Brendan Eich wrote: >> >>> How about something like this? >>> >>> spawn(function *() { >>> var gen = this.thread; >>> >>> stream.on('data', function (data) { >>> gen.send(data); >>> }); >>> >>> console.log(yield gen.next()); >>> }); >>> >> >> Sorry, a generator instance can't next itself, so that last statement >> should be: >> >> console.log(yield undefined); >> >> We just need to park the task before console.log is invoked, such that >> the data the listener receives is sent to the paused task's generator and >> becomes theactual argument to console.log. >> >> /be >> > > > > -- > *'I am what I am because of who we all are'* > h3manth.com <http://www.h3manth.com> > *-- Hemanth HM * >
_______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

