function.sent beta equivalence?

Andreas Rossberg rossberg at google.com
Mon Jun 29 17:20:18 UTC 2015


On 24 June 2015 at 22:56, Jason Orendorff <jason.orendorff at gmail.com> 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
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20150629/66637f05/attachment.html>


More information about the es-discuss mailing list