Tail calls
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.
Good point, thanks.
The Expressions section doesn't note tail call position in conditionals (which are not user-definable operators).
Another good catch.
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).
It's a little informal at this point, but the intention was that S ranges over statements, which includes BlockStatements, and C ranges over switch clauses. But I'll make sure these details get tightened up when we do start making things more formal.
Thanks for the helpful feedback!
,
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).