Oliver Hunt (2013-10-27T03:11:47.000Z)
On Oct 26, 2013, at 4:59 PM, Lucio Tato <luciotato at gmail.com> wrote:

> Rick: I understand. But it is always a trade-off.
> 
> If the reason to introduce a new construct is because there may already be code that defines a function called `yield`, it seems to me as a bad trade-off. (advantages vs disadvantages)
> 
> In your example... 
> function yield() {... <- will raise a parsing error.
> 

You can’t make yield a reserved word — which is what you’re asking for here.  This isn’t a matter of whether or not you use generators, it’s a matter of whether other code in the same environment ever uses a property named yield.  All of the options necessarily require breaking yield in existing code


> Anyway, there are other ways to solve that.
> You can put the asterisk in "yield" instead of the important "function". It's a lot less confusing.
> 
> function fibonacci() {
>     let [prev, curr] = [0, 1];
>     for (;;) {
>         [prev, curr] = [curr, prev + curr];
>         yield*(curr);

This already parses a (yield)*(curr)

Please stop trying to get rid of the *, there isn’t any other viable option, and this has been covered ad nauseum on es-discuss

—Oliver
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20131026/a2e98217/attachment.html>
domenic at domenicdenicola.com (2013-11-02T19:03:47.486Z)
On Oct 26, 2013, at 4:59 PM, Lucio Tato <luciotato at gmail.com> wrote:

> Rick: I understand. But it is always a trade-off.
> 
> If the reason to introduce a new construct is because there may already be code that defines a function called `yield`, it seems to me as a bad trade-off. (advantages vs disadvantages)
> 
> In your example... 
>
> ```
> function yield() {... <- will raise a parsing error.
> ```

You can’t make yield a reserved word — which is what you’re asking for here.  This isn’t a matter of whether or not you use generators, it’s a matter of whether other code in the same environment ever uses a property named yield.  All of the options necessarily require breaking yield in existing code


> Anyway, there are other ways to solve that.
> You can put the asterisk in "yield" instead of the important "function". It's a lot less confusing.
> 
> ```js
> function fibonacci() {
>     let [prev, curr] = [0, 1];
>     for (;;) {
>         [prev, curr] = [curr, prev + curr];
>         yield*(curr);
> ```

This already parses a (yield)*(curr)

Please stop trying to get rid of the *, there isn’t any other viable option, and this has been covered ad nauseum on es-discuss