Re:Show HN: Tail Recursion Optimization for the JVM
by Gollapalli on Wednesday April 22, 2020 @01:30PM
(#22948041)
This is exciting. I'm guessing since it applies to bytecode it works for clojure as well? That would mean we'll be able to use (func (when cond function)) instead of (loop [] (recur)).
[ Parent
| on HN ]
Re:Show HN: Tail Recursion Optimization for the JVM
by hencq on Wednesday April 22, 2020 @02:14PM
(#22948510)
The use of recur in Clojure is by design. It would have been quite trivial to optimize this type of self recursion, but since it doesn't do general tail call optimization, they introduced the recur keyword. See also [1]. By the way, you don't need to use loop in Clojure either, it also works with functions.
[1]. https://clojure.org/about/functional_programming#_recursive_...