proper tail calls

Brendan Eich brendan at
Mon Jan 21 14:14:03 PST 2008

On Jan 21, 2008, at 1:11 PM, Jeff Dyer wrote:

> On 1/21/08 12:35 PM, Brendan Eich wrote:
>> So the axes of disagreement seem to me to be:
> We need to agree on the primary purpose of proper tail calls. I say  
> it is
> portability of code, and that all other concerns do not have enough  
> weight
> to influence this proposal.

I'm pretty sure you mean the primary purpose (or reason) for  
*specifying* proper tail calls, not the purpose of proper tail calls  
for state machines, loops, and other call graphs that (absent other  
allocations) must not accumulate space. If we wanted to dig in our  
heels and repeat "use iteration" (Python sticks to this gun), we could.

But we have accepted the proper tail calls proposal for a long while,  
to serve such currently poorly-served use-cases. We have to evaluate  
the syntax as well as semantics against usability and other criteria  
in light of those use-cases. Portability is an end, but not the only  

The mention of GC is apposite: if implementations don't agree on GC  
scheduling, or some use ref-counting, you can write programs that  
fall over (as in, hit a hard memory limit) by coding for one  
particular memory manager. That's obviously a bad idea, but the ES4  
spec can't require a particular memory management algorithm "for  

>> 1. explicit vs. implicit,
> Since PTC is about portability of code then what matters most is that
> implementations agree on what a tail call is. If the spec is  
> unambiguous
> about what a tail call is, then implementations will have little  
> trouble
> agreeing. Anyway, an explicit marking won't help.

Sure, that's clear. But ticket 323 cites benefits of explicit syntax:  
automated checking for the programmer, clues to the readers  
(especially the debugger drivers), new syntax for a new (to ES1-3 and  
real JS implementations) storage rule.

In other words, humans programming in the langauge might benefit from  
explicit syntax, even if compilers and the (fewer, more expert)  
humans who write them can get implicit proper tail calls right.

>> 2. whether to have a tail annotation if implicit,
> Ditto. It won't aid in ensuring portability of code.

That's not the only end; another good to serve here is correctness.

>> 4. whether explicit is required for debug-ability.
> PTC should not be for improving debug-ability.

The argument (which I do not think is decisive) is that PTC breaks  


More information about the Es4-discuss mailing list