That First Next Argument

Kevin Smith zenparsing at gmail.com
Tue Aug 19 06:21:15 PDT 2014


>
>
> // the same, advancing to the first `yield` at instantiation
> class echo2 extends echo {
>     construct(...args) {
>         let iter = super(...args)
>         iter.next()
>         return iter
>     }
> }
>

Nice pattern!  Would this also work?

    var skipFirst = genFn => function*(...args) {
        var iter = genFn(...args);
        iter.next();
        yield * iter;
    };

    var echo2 = skipFirst(echo);

If we have decorators, then we can write:

    @skipFirst
    function echo() { /*_*/ }

which is fairly pleasant.

Still, it seems like we're papering over a hole.  In principle, why
shouldn't we be able to access the first next argument?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20140819/d7a8285e/attachment.html>


More information about the es-discuss mailing list