Closed ljharb closed 5 years ago
I would intend for this to work, and will update the explained accordingly when time permits.
This example is illustrated in https://github.com/tc39/proposal-partial-application#semantics:
In addition to fixing the function to be called and its explicit arguments, we also fix any supplied receiver as part of the resulting function, as we will store the Reference in the resulting function. As such,
o.f(?)
will maintaino
as thethis
receiver when callingo.f
. This can be illustrated by the following syntactic conversion:const g = o.f(?, 1);
is roughly identical in its behavior to:
const g = (() => { const receiver = o; const fn = o.f; const p0 = 1; return (a0) => fn.call(receiver, a0, p0); })();
Please feel free to point me at the right place if this is a duplicate.
I find it very important that
const x = a.b(?, d); delete a.b; a = null; x(c)
work - ie, that the receiver and the function are eagerly preserved at the moment of evaluating the partial application.This allows for method extraction, such that I can do something like: