function.sent beta equivalence?

Jason Orendorff jason.orendorff at
Wed Jun 24 20:56:02 UTC 2015

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

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


More information about the es-discuss mailing list