proper tail calls

Brendan Eich brendan at
Tue Jan 22 12:31:59 PST 2008

On Jan 22, 2008, at 12:14 PM, Lars T Hansen wrote:

> Ergo some implementations will have this
> improvement; users will start depending on it; other implementations
> will follow; and the explicit syntax is useful *only* as an assert
> that the tail call can in fact take place, and will be useful only to
> people who know about it and value it.  Like type annotations, I
> guess.

Ding ding ding....

> IMO, the best design is that (a) a call that is syntatically in tail
> position is executed as a tail call when that is possible, but as a
> non-tail call when type conversions or type checking interferes, and
> that this happens without the programmer having to think about it, and
> (b) an annotation ("goto",

"tail" ;-)

> whatever) can be used to check that the
> tail call is in fact possible, and it will cause an error (at compile
> time in strict mode, possible) if that is not possible.  Thus we have
> tail call annotations like we have type annotations; people use them
> if they feel that provides benefit.  For everyone else it "just works
> except when it doesn't" -- again, exactly like typing.

This works for me. The desire for explicitude was well-intentioned  
but misdirected. It has found its target: an optional syntax for  
asserting a tail call. Thanks to all (esp. Jon Zeppieri for putting  
the assertion idea down in the bug) for this discussion (it helped  
crystalize things for me, at least).


More information about the Es4-discuss mailing list