Mark S. Miller wrote:
On Tue, Jul 16, 2013 at 10:54 AM, Claus Reinke <[email protected] <mailto:[email protected]>> wrote:

       // this doesn't work
       function* generator(){
           [1,2,3].forEach( function(x){ yield x } )

       }

        This would make generators deep, violating the
        non-interleaving assumptions
        of intermediate callers on the call stack. This is why we accepted
        generators only on condition that they be shallow. We knew at
        the time that
        this privileges built-in control structures over user defined
        ones. The
        alternative would have been to omit generators completely. We
        agree that
        shallow generators were worth it, despite this non-uniformity.


    While I understand the compromise, and the wish to get in some form
    of generators anyway, the discrimination against user-defined control
    structures troubles me deeply.


Troubles me too. As of ES6 the only possible alternative would be to remove generators from the language. I can't see that happening.

That would be somewhere between "making the perfect the enemy of the good" and "cutting off your nose to spite your face".

If we want call/cc (plus macros to sugar it into usability), there's the door -- it ain't in JS outside of Rhino, and (for good reasons you adduce) it won't be added.

But we have good use cases for generators, including to implement iterators independent of async. programming.

For async we're looking at defer/await for ES7.

This is how living languages evolve. Sorry to preach to the choir (I hope :-P).

/be
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to