That First Next Argument

Brendan Eich brendan at mozilla.org
Thu Aug 21 09:54:58 PDT 2014


Andy Wingo wrote:
> On Wed 20 Aug 2014 19:55, Brendan Eich<brendan at mozilla.org>  writes:
>
>> >  Kevin Smith wrote:
>>> >>       function *echo() input {
>>> >>           while (true) yield input.value;
>>> >>       }
>> >
>> >  So input is bound to the next() actual parameter value on each
>> >  resumption. That's not bad shed-coloring!
>> >
>> >  Andy, Dave: WDYT?
>
> I think changing things right now is the wrong thing to do.  Since this
> is a compatible extension, we don't have to think about this for ES6.
> Just putting that out there;)

Oh definitely -- es-discuss and twitter folks need to assume ES6 is 
done. Train model starting, annual editions if we do it right. Any 
compatible extension can catch next year's train. This means 
implementation at the agreed upon stage 2, usually much sooner than next 
year. See

https://docs.google.com/document/d/1QbEE0BsO4lvl7NFTn5WXWeiEIBfaVUF7Dk0hpPpPDzU/edit

(Allen: is this the canonical location?)

> That said, first thoughts:
>
>    * I assume "input" could then be captured by nested scopes.  This
>      would be a bit strange but could work.

It should act like a strict parameter binding (no 
arguments[arguments.length] alias!).

>    * Really you'd want to be able to destructure too, as you can in every
>      other part of the grammar that introduces names.  That's probably
>      not a great thing to do here, though.

That would require bracketing, or at least a connecting punctuator. 
Could be done.

>    * I assume Kevin meant:
>
>        function *echo input { while (true) yield input }
>
> To me it smells, but perhaps that is just my grumpiness;)

(Grumpy enough not to cuddle * with function :-P.)

Why no () after echo for the empty parameter list? That's a surprise.

Yeah, no .value needed (Kevin can confirm).

> Explicitly being able to place the initial yield would be nicer, but
> then it's more difficult to ensure that the initial yield comes before
> other yields.

Right.

> I say punt;)

For ES6, of course. Seems fair es-discuss fodder for future Harmony 
inclusion.

/be


More information about the es-discuss mailing list