Are there any Java compilers out there that optimize tail-recursion into a loop using constant memory?
I'm running Java 1.4.1 on my Mac, and tried running the following three methods to see whether the compiler was making this optimization, and it wasn't: tailRecursiveSum crashed with a stack overflow around num=6445. I would have expected the recursiveSum method to stack-overflow, but if the compiler were optimizing tail-recursion (as is specified in Scheme), tailRecursiveSum would not stack-overflow, no matter how large a positive number I gave it.
I'm running Java 1.4.1 on my Mac, and tried running the following three methods to see whether the compiler was making this optimization, and it wasn't: tailRecursiveSum crashed with a stack overflow around num=6445. I would have expected the recursiveSum method to stack-overflow, but if the compiler were optimizing tail-recursion (as is specified in Scheme), tailRecursiveSum would not stack-overflow, no matter how large a positive number I gave it.