Jason Orendorff wrote:
I think Allen is proposing a scheme where in code like

     function f(a1=EXPR1, a2=EXPR2, a3=EXPR3) { ... }
     f();

first EXPR1 is evaluated in a scope including only a1,
then EXPR2 is evaluated in a scope that contains a1 and a2,
then EXPR3 is evaluated in a scope that contains a1, a2, and a3,
then a new environment is created for the function body, its vars and
local functions.

Actually Allen was just reminding me of a TC39 meeting's agreement to bind formals from the left, as if by let* (from Scheme) -- and a1 would not be bound in EXPR1's scope, so any a1 used in EXPR1 would be from an outer scope, etc.

This is without precedent in JS.

Since Kevin was really getting at where the implicit yield goes in

  function* f(a1 = E1, ~~~ aN = EN) {
    ~~~
  }

where ~~~ is meta-ellipsis, and he agreed the activation scope for all parameter default expressions is simpler (and thanks to both of you for clarifying and separating issues here), we're left with the implicit yield placement issue.

I wonder whether we can't shed light on this issue by looking at the thinnest basis case of a generator with an observable default parameter:

  let n = 0;
  function *gen(a = ++n) {}
  for (let x of gen()) {}
  assert(n === 1);

Does this help?

/be
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to