Re: function.next meta-property proposal
In Python, sending a value other than `None` into the first invocation of `send` raises an error. That seems like a reasonable behaviour to me, without introducing too much weirdness. TypeError: can't send non-None value to a just-started generator On Thursday, May 14, 2015, Allen Wirfs-Brock al...@wirfs-brock.com wrote: At the March TC39 meeting we agreed that the `function.next` metapropty should be made into a standalone stage 1 proposal. That proposal is now available at: https://github.com/allenwb/ESideas/blob/master/Generator%20metaproperty.md Allen ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss
Re: function.next meta-property proposal
Alexander ES6 is out as it is, here the proposal is to make reachable that argument because indeed, since about ever, in JS you can ignore arguments, but you can also always reach them through the argument object. When it comes to generators, arguments object would be a misleading place to give you any sent value 'cause that's rather how you initialize the generator, hence the function.nect proposal, and I must say I like it in all its weird glory. Like you said, Python throws, meaning devs coming from Python won't ever make such mistake of sending values a tthe very first `.next` invoke, so JS early adopters know thanks to all bounce of early articles regarding the early specs :D My only concern, is that the famous Promise based generator wrap https://www.promisejs.org/generators/#both needs an update: ```js function async(makeGenerator){ return function (value) { // = here var generator = makeGenerator.apply(this, arguments); function handle(result){ // result = { done: [Boolean], value: [Object] } if (result.done) return Promise.resolve(result.value); return Promise.resolve(result.value).then(function (res){ return handle(generator.next(res)); }, function (err){ return handle(generator.throw(err)); }); } try { return handle(generator.next(value)); // = here } catch (ex) { return Promise.reject(ex); } } } ``` Best Regards On Thu, May 14, 2015 at 11:25 PM, Alexander Jones a...@weej.com wrote: I don't think that's a good enough reason by itself to make this observable. You can pass arbitrary numbers of arguments to any function in JS, and they are generally ignored. On Thursday, 14 May 2015, Kevin Smith zenpars...@gmail.com wrote: Alexander, ES6 generators accept any arbitrary values for the first invocation of next. That's not going to change. On Thu, May 14, 2015 at 3:49 PM Alexander Jones a...@weej.com wrote: In Python, sending a value other than `None` into the first invocation of `send` raises an error. That seems like a reasonable behaviour to me, without introducing too much weirdness. TypeError: can't send non-None value to a just-started generator On Thursday, May 14, 2015, Allen Wirfs-Brock al...@wirfs-brock.com wrote: At the March TC39 meeting we agreed that the `function.next` metapropty should be made into a standalone stage 1 proposal. That proposal is now available at: https://github.com/allenwb/ESideas/blob/master/Generator%20metaproperty.md Allen ___ 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 ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss
Re: function.next meta-property proposal
Alexander, ES6 generators accept any arbitrary values for the first invocation of next. That's not going to change. On Thu, May 14, 2015 at 3:49 PM Alexander Jones a...@weej.com wrote: In Python, sending a value other than `None` into the first invocation of `send` raises an error. That seems like a reasonable behaviour to me, without introducing too much weirdness. TypeError: can't send non-None value to a just-started generator On Thursday, May 14, 2015, Allen Wirfs-Brock al...@wirfs-brock.com wrote: At the March TC39 meeting we agreed that the `function.next` metapropty should be made into a standalone stage 1 proposal. That proposal is now available at: https://github.com/allenwb/ESideas/blob/master/Generator%20metaproperty.md Allen ___ 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: function.next meta-property proposal
actually, that won't work ... so yeah, that pattern is somehow compromise, arguments is used to indeed initialize the generator, no way to put first value in ... oh well On Thu, May 14, 2015 at 11:44 PM, Andrea Giammarchi andrea.giammar...@gmail.com wrote: Alexander ES6 is out as it is, here the proposal is to make reachable that argument because indeed, since about ever, in JS you can ignore arguments, but you can also always reach them through the argument object. When it comes to generators, arguments object would be a misleading place to give you any sent value 'cause that's rather how you initialize the generator, hence the function.nect proposal, and I must say I like it in all its weird glory. Like you said, Python throws, meaning devs coming from Python won't ever make such mistake of sending values a tthe very first `.next` invoke, so JS early adopters know thanks to all bounce of early articles regarding the early specs :D My only concern, is that the famous Promise based generator wrap https://www.promisejs.org/generators/#both needs an update: ```js function async(makeGenerator){ return function (value) { // = here var generator = makeGenerator.apply(this, arguments); function handle(result){ // result = { done: [Boolean], value: [Object] } if (result.done) return Promise.resolve(result.value); return Promise.resolve(result.value).then(function (res){ return handle(generator.next(res)); }, function (err){ return handle(generator.throw(err)); }); } try { return handle(generator.next(value)); // = here } catch (ex) { return Promise.reject(ex); } } } ``` Best Regards On Thu, May 14, 2015 at 11:25 PM, Alexander Jones a...@weej.com wrote: I don't think that's a good enough reason by itself to make this observable. You can pass arbitrary numbers of arguments to any function in JS, and they are generally ignored. On Thursday, 14 May 2015, Kevin Smith zenpars...@gmail.com wrote: Alexander, ES6 generators accept any arbitrary values for the first invocation of next. That's not going to change. On Thu, May 14, 2015 at 3:49 PM Alexander Jones a...@weej.com wrote: In Python, sending a value other than `None` into the first invocation of `send` raises an error. That seems like a reasonable behaviour to me, without introducing too much weirdness. TypeError: can't send non-None value to a just-started generator On Thursday, May 14, 2015, Allen Wirfs-Brock al...@wirfs-brock.com wrote: At the March TC39 meeting we agreed that the `function.next` metapropty should be made into a standalone stage 1 proposal. That proposal is now available at: https://github.com/allenwb/ESideas/blob/master/Generator%20metaproperty.md Allen ___ 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 ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss
Re: function.next meta-property proposal
I don't think that's a good enough reason by itself to make this observable. You can pass arbitrary numbers of arguments to any function in JS, and they are generally ignored. On Thursday, 14 May 2015, Kevin Smith zenpars...@gmail.com wrote: Alexander, ES6 generators accept any arbitrary values for the first invocation of next. That's not going to change. On Thu, May 14, 2015 at 3:49 PM Alexander Jones a...@weej.com javascript:_e(%7B%7D,'cvml','a...@weej.com'); wrote: In Python, sending a value other than `None` into the first invocation of `send` raises an error. That seems like a reasonable behaviour to me, without introducing too much weirdness. TypeError: can't send non-None value to a just-started generator On Thursday, May 14, 2015, Allen Wirfs-Brock al...@wirfs-brock.com javascript:_e(%7B%7D,'cvml','al...@wirfs-brock.com'); wrote: At the March TC39 meeting we agreed that the `function.next` metapropty should be made into a standalone stage 1 proposal. That proposal is now available at: https://github.com/allenwb/ESideas/blob/master/Generator%20metaproperty.md Allen ___ es-discuss mailing list es-discuss@mozilla.org javascript:_e(%7B%7D,'cvml','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