Tail calls

Jeff Walden jwalden+es4 at MIT.EDU
Mon Mar 26 23:53:43 PDT 2007



In the Specification section, I'd prefer if "return an undefined value" were changed to "return *undefined*" or "return the undefined value", since the returned value is very much defined in these cases.


The Expressions section doesn't note tail call position in conditionals (which are not user-definable operators).

function foo(x, y, c)
  if (c)
    return x || frob(y);
  return x && frob(y);

Both calls |frob(y)| are in tail position, because the value each returns (if evaluated) is returned from |foo|.  I believe the following additions clarify this:

E -> E1 || E2                  E2.tail = E.tail
E -> E1 && E2                  E2.tail = E.tail


On a pedantic note, S1/S2 in try, C1..n in switch, and S in catch should be braced, unless their syntaxes changed to Statement from BlockStatement from ES3->4 (I haven't looked).


Rediscover the Web!

Reclaim Your Inbox!

More information about the Es4-discuss mailing list