tc39 / proposal-partial-application

Proposal to add partial application to ECMAScript
https://tc39.es/proposal-partial-application/
BSD 3-Clause "New" or "Revised" License
1.02k stars 25 forks source link

issue within the example for illustrating semantic rules #9

Closed royling closed 5 years ago

royling commented 7 years ago
let o = { f(x, y) { return x + y + this.z; }, z: 0 };

const g = o.f(?, 3);
g(1); // 4

// ...

// replace the value of `o.f`
o.f = (x, y) => x * y;
g(1); // 5  <-- isn't it expected to return 3?

isn't here g(1) expected to return 3 instead? the function o.f is changed to only multiply x and y.

or do you mean to rewrite the o.f as:

o.z = 2
o.f = function (x, y) { return x * y + this.z }

I expect that would return 5 given this is fixed as o in that case.

rbuckton commented 5 years ago

The examples have been updated with respect to eager evaluation and the above sample is no longer present.