Tail calls

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


http://developer.mozilla.org/es4/proposals/proper_tail_calls.html


First:

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.


Second:

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


Third:

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).

Jeff

-- 
Rediscover the Web!
http://snurl.com/get_firefox

Reclaim Your Inbox!
http://snurl.com/get_thunderbird



More information about the Es4-discuss mailing list