Quick question about function.sent:

As of ES6, there's this parallel between functions and generators:

    // how to wrap a function
    // f2 is equivalent to f, if f doesn't use `this`.
    function f(...) { ... }
    function f2(...args) { return f(...args); }

    // how to wrap a generator
    // g2 is equivalent to g, if g doesn't use `this`.
    function* g(...) { ... }
    function* g2(...args) { return yield* g(...args); }

That is, λx.f(x) = f, a sort of beta-equivalence rule, and for
generators, you just need to add `yield*` to get an analogous rule. My
understanding is that this is one reason we have `yield*`. (Writing a
wrapping function/generator that also covers `this` is left as an easy
exercise.)

Given function.sent, is there still a way to "wrap" a generator?

-j
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to