Re: .next('yo') in newborn generators
On Feb 25, 2014, at 5:04 AM, Erik Arvidsson wrote: > I think we can settle this now. > > Lets allow an argument. Fine by me. I'd be happy to make the change now and confirm it at the next meeting. I'm not expecting any push back. Allen ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss
Re: Fwd: .next('yo') in newborn generators
I think we can settle this now. Lets allow an argument. On Tuesday, February 25, 2014 6:27:26 AM, Brendan Eich wrote: > Andy Wingo wrote: > > Hi, > > > > I don't see the point of throwing an error when calling .next('foo') on > > a newborn generator. We don't throw an error on .next('foo', 'bar'), > > and unlike the case with most function calls there is no way to get the > > 'bar' when resuming a generator, as you don't have an arguments object. > > > > I would punt on this issue entirely, and ideally remove the > > "suspendedStart" state from the spec, renaming "suspendedYield" to > > simply "suspended". > > > > Just MHO:) > > I agree, and I thought we agreed at the last TC39 meeting, but I was > wrong or else it got lost. > > We'll settle it at the early April meeting. > > /be > ___ > es-discuss mailing list > es-discuss@mozilla.org > https://mail.mozilla.org/listinfo/es-discuss > ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss
Re: Fwd: .next('yo') in newborn generators
Andy Wingo wrote: Hi, I don't see the point of throwing an error when calling .next('foo') on a newborn generator. We don't throw an error on .next('foo', 'bar'), and unlike the case with most function calls there is no way to get the 'bar' when resuming a generator, as you don't have an arguments object. I would punt on this issue entirely, and ideally remove the "suspendedStart" state from the spec, renaming "suspendedYield" to simply "suspended". Just MHO:) I agree, and I thought we agreed at the last TC39 meeting, but I was wrong or else it got lost. We'll settle it at the early April meeting. /be ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss
Re: Fwd: .next('yo') in newborn generators
Hi, I don't see the point of throwing an error when calling .next('foo') on a newborn generator. We don't throw an error on .next('foo', 'bar'), and unlike the case with most function calls there is no way to get the 'bar' when resuming a generator, as you don't have an arguments object. I would punt on this issue entirely, and ideally remove the "suspendedStart" state from the spec, renaming "suspendedYield" to simply "suspended". Just MHO :) Andy ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss
Re: Fwd: .next('yo') in newborn generators
Linking to some Twitter discussion related to this: https://twitter.com/bradleymeck/status/436371508005326850 On Thu, Feb 20, 2014 at 3:03 AM, David Bruant wrote: > Le 20/02/2014 06:39, Brendan Eich a écrit : > > Bradley Meck wrote: >> >>> >>> If I am reading the spec right (and I may not be), only the generator >>> should fail? The first call to gen().next(value) must have value be >>> undefined, and the others do not check. >>> >> >> I thought we agreed at the January 28 meeting to get rid of this error, >> but I can't find it in the notes. The January meeting notes have missed >> other conclusions, though. Allen? >> > https://github.com/rwaldron/tc39-notes/blob/master/es6/2014-01/jan-28.md# > concensusresolution > "BN: Have to go back and think more about this. Maybe a helper function > can be created." > It looks like no ferm decision has been made yet. > > David > ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss
Re: Fwd: .next('yo') in newborn generators
Le 20/02/2014 06:39, Brendan Eich a écrit : Bradley Meck wrote: If I am reading the spec right (and I may not be), only the generator should fail? The first call to gen().next(value) must have value be undefined, and the others do not check. I thought we agreed at the January 28 meeting to get rid of this error, but I can't find it in the notes. The January meeting notes have missed other conclusions, though. Allen? https://github.com/rwaldron/tc39-notes/blob/master/es6/2014-01/jan-28.md#concensusresolution "BN: Have to go back and think more about this. Maybe a helper function can be created." It looks like no ferm decision has been made yet. David ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss
Re: Fwd: .next('yo') in newborn generators
Bradley Meck wrote: If I am reading the spec right (and I may not be), only the generator should fail? The first call to gen().next(value) must have value be undefined, and the others do not check. I thought we agreed at the January 28 meeting to get rid of this error, but I can't find it in the notes. The January meeting notes have missed other conclusions, though. Allen? /be ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss
Fwd: .next('yo') in newborn generators
take for example a function that accepts an iterator: ```javascript function test(name, iterable) { try { var iterator = iterable[Symbol.iterator](); console.log(name,'with value for first next', iterator.next(1)) } catch(e) { console.error(name,'failed value for first next', e); } } var arr = [1,2]; var set = new Set({first:true},{second:true}); var str = 'ab'; var gen=function*(){ yield 1; yield 2; }; test('array', arr); test('set', set); test('string', str); test('generator', gen()); ``` If I am reading the spec right (and I may not be), only the generator should fail? The first call to gen().next(value) must have value be undefined, and the others do not check. ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss
Re: .next('yo') in newborn generators
Bradley Meck wrote: Digging up old threads, but is there a way to test for newborn generators? No. To my knowledge they are the only iterable that does not allow a value to be passed in at a specific time. What do you mean by "does not allow"? /be ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss
Re: Re: .next('yo') in newborn generators
Digging up old threads, but is there a way to test for newborn generators? To my knowledge they are the only iterable that does not allow a value to be passed in at a specific time. ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss
Re: .next('yo') in newborn generators
Le 15/01/2014 17:50, Allen Wirfs-Brock a écrit : On Jan 15, 2014, at 8:32 AM, David Bruant wrote: Hi, Playing with the test cases of the regenerator project [1], I came across a case and was wondering what the intention of the spec is given that Firefox and Chrome recent implementations diverge. Apologies for not reading all the previous discussions on this edge case. Test case: js function *gen(x) { yield x; } var g = gen('whatever'); console.log(g.next(0)); Chrome & regenerator: {value: "whatever", done: false} Firefox (Aurora 28): TypeError: attempt to send 0 to newborn generator From what I understand, the spec says an error should be thrown because the generator is in "suspendedStart" state and value is not undefined (25.3.3.2 GeneratorResume step 7). Yes, that's what the spec, requires. This check was in the the original Generator proposal http://wiki.ecmascript.org/doku.php?id=harmony:generators#internal_methodsend It's an error because there is no mechanism for a generator to receive the argument passed by the first next. Sounds good. Bugs on V8 and regenerator for those interested: https://code.google.com/p/v8/issues/detail?id=3099 https://github.com/facebook/regenerator/issues/76 David ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss
Re: .next('yo') in newborn generators
On Jan 15, 2014, at 8:32 AM, David Bruant wrote: > Hi, > > Playing with the test cases of the regenerator project [1], I came across a > case and was wondering what the intention of the spec is given that Firefox > and Chrome recent implementations diverge. > Apologies for not reading all the previous discussions on this edge case. > > Test case: > js > function *gen(x) { >yield x; > } > > var g = gen('whatever'); > console.log(g.next(0)); > > > Chrome & regenerator: > {value: "whatever", done: false} > > Firefox (Aurora 28): > TypeError: attempt to send 0 to newborn generator > > From what I understand, the spec says an error should be thrown because the > generator is in "suspendedStart" state and value is not undefined (25.3.3.2 > GeneratorResume step 7). Yes, that's what the spec, requires. This check was in the the original Generator proposal http://wiki.ecmascript.org/doku.php?id=harmony:generators#internal_methodsend It's an error because there is no mechanism for a generator to receive the argument passed by the first next. Allen ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss
.next('yo') in newborn generators
Hi, Playing with the test cases of the regenerator project [1], I came across a case and was wondering what the intention of the spec is given that Firefox and Chrome recent implementations diverge. Apologies for not reading all the previous discussions on this edge case. Test case: js function *gen(x) { yield x; } var g = gen('whatever'); console.log(g.next(0)); Chrome & regenerator: {value: "whatever", done: false} Firefox (Aurora 28): TypeError: attempt to send 0 to newborn generator From what I understand, the spec says an error should be thrown because the generator is in "suspendedStart" state and value is not undefined (25.3.3.2 GeneratorResume step 7). Where do I file bugs? David [1] https://github.com/facebook/regenerator/blob/master/test/tests.es6.js ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss