Forums Register Login

tail recursion

+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
Have you tried the -server option when running your test?

Googling for "java tail recursion" also gives a bunch of interesting hits...
You will always be treated with dignity. Now, strip naked, get on the probulator and hold this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 1096 times.
Similar Threads
Question about mem allocation for recursive functions
Timing Methods
Tail Calls vs memoization
how to convert currency figures
Stacks
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 09:25:50.