yield* desugaring

Brendan Eich brendan at mozilla.com
Mon May 13 21:44:19 PDT 2013


David Herman wrote:
> On May 13, 2013, at 6:11 PM, Brendan Eich<brendan at mozilla.com>  wrote:
>
>> Merge next and send by letting next take an optional parameter? Ok by me.
>
> +1

I pointed out to Dave that Python has arity checking and did next before 
adding send in 2.5 for "coroutines", whereas JS has optional params 
without arity checking, so folding send into next works.

>> Make yield* work on any {next, throw}, not necessary but ok by me too.
>
> Yes with one delta: if there's no .throw it still works, it just defaults to (x) =>  { throw x }. This way you can write ordinary iterators without having to worry about providing the default throw, and they still function properly as generators.

+1 or more -- we should not invent new nominal types with stub throw 
method implementations, people will not use them and they are 
unnecessary boilerplate.

/be


More information about the es-discuss mailing list