[plt-scheme] guido on tail recursion

From: Prabhakar Ragde (plragde at uwaterloo.ca)
Date: Sat Apr 25 20:23:43 EDT 2009

Eli Barzilay wrote:

> I once looked at the code that GCC generates for mutually recursive
> even/odd, with tail-call optimizations, and the machine code really
> impressed me.  Doing that again, I get this with -O2 (translating the
> assembly code):
>     is_odd:
>       if n=0 return 0
>       n -= 1
>     is_even:
>       if n=0 return 1
>       n -= 1
>       goto is_odd

Throw a dummy parameter into one of your functions and watch a goto turn 
into a call. I just checked this. I think it will also happen with a 
local variable that can't be optimized away, or if odd and even are in 
separate files. --PR

Posted on the users mailing list.