On 24 June 2015 at 22:56, Jason Orendorff <[email protected]> wrote:
> 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,
Nitpick: this equivalence is eta, not beta. Unfortunately, I don't have
anything more profound to add.
But it's a good question. Maybe it's an indication that we should not add
function.sent?
/Andreas
> 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
> [email protected]
> https://mail.mozilla.org/listinfo/es-discuss
>
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss