Call tail in Java and C #?

I read about Clojure and found a discussion that Java does not support tail calls in the current version and that people are throwing exceptions to simulate tail calls in the JVM, anyway it looks like people are doing some crazy stuff there. So this made me wonder about calling C # tail, about the same problems?

+1


source to share


2 answers


CLR code will call the call in some cases, but not in others - it depends on the JIT.

See the blog post by David Broman and Sri Borde too.



The C # compiler does not currently generate an IL tail call, but sometimes the JIT does it anyway.

+6


source


Tail recursion is possible in some cases on the JVM. For example, Scala asks for an efficient implementation of basic tail recursion (see this blog post, search for Trivia Language # 8 , just the quote I could only find now). There is talk and research about adding additional support in the same effort as Invoke Dynamic and other non-Java-specific features.

It is also quite common to discuss such problems in Java Posse .



And yes, I know this is completely not an answer to your question ...

+1


source







All Articles