4 ms·
Clojure has a loop/recur construct which makes the tail recursion explicit so doesn't need to be done by the JVM. In other words regular recursive calls should
by justinhj 14y ago
Clojure has a loop/recur construct which makes the tail recursion explicit so doesn't need to be done by the JVM. In other words regular recursive calls should not be used for loops if you want performance.
- riffraff 14y agoI think rail recursion can be handled automatically by the compiler without any support from the jvm (scala does it). The issue is different for general tail call elimination.
- pohl 14y agoScala has a similar explicit @Tailrec annotation for its compiler, too: "A method annotation which verifies that the method will be compiled with tail call optimization. If it is present, the compiler will issue an error if the method cannot be optimized into a loop." http://www.scala-lang.org/api/current/index.html#scala.annotation.tailrec http://www.scala-lang.org/api/current/index.html#scala.annot...