proper tail calls

Dave Herman dherman at ccs.neu.edu
Mon Jan 21 16:57:47 PST 2008


> I am a bit out of my depth in this discussion, but explicit syntax
> feels wrong to me. However, if it's going to be implicit, it has to be
> completely invisible (aside from the benefits) - developers are going
> to want their debugging tools to work as before.
> 
> Is there a practical approach to recursion counting, that ES4 could
> require, so that Error.getStackTrace() can use it to produce the
> "expected" result?  I must admit, It doesn't feel as trivial in my
> head as that sentence reads...

You can easily circumvent an expression being in tail position. For 
example, if EXP is in tail position and you want it not to be, just wrap 
it as:

     let (r = EXP) r

The program behaves the same, except for the fact that EXP is no longer 
in tail position, so it cannot perform a tail call.

Dave



More information about the Es4-discuss mailing list