I was reading about Clojure and found a discussion about Java not supporting tail calls, in the current version, and that people were throwing exceptions to simulate tail calling in the JVM, anyways it sounds like people are doing some crazy stuff out there. So this got me wondering about C#'s tail calling, same issues?
+4
A:
CLR code will tail call in some cases but not others - it depends on the JIT.
See David Broman's blog entry and Shri Borde's one too.
The C# compiler doesn't currently emit tail call IL, but sometimes the JIT will do it anyway.
Jon Skeet
2008-12-09 15:12:12
nice articles, so the tracing GC is why the tail-calling is limited.
Robert Gould
2008-12-09 15:41:43
+1
A:
Tail recursion is possible on the JVM in certain cases. For example, Scala asks for an efficient implementation of basic tail recursion (see this blog post, look for Language Trivia #8, only quote I could find just now). There is talk and research about adding more support, in the same effort as Invoke Dynamic and other features specialized for non-Java languages.
There is also quite often talks about those kind of issues on The Java Posse.
And yes, I know that this is totally not an answer to your question ...
Guillaume
2008-12-09 15:30:52