by treerex · 11y ago · 0 comments
The lack of TCO in JVM hosted languages is besides the point.
It is also possible for the Clojure compiler to do TCO in certain cases: Rich Hickey made the conscious decision to not do it.
If I read your statement as Rich Hickey having the opportunity but passed on it, I'd reply that he did that with recur. Unless you mean silent TCO like e.g. Scheme does.
It certainly looks more elegant to do it silently, but Clojure doesn't strive for that sort of elegance.
Personally, I like clojure's approach as IMHO recur makes intent clear, but recur is a subset of what TCO optimises in other languages.
(defun foo () (foo)) ;<- tail call
(defun bar () (bar)) ;<- tail call
(defun baz (a b) (+ ;<- tail call
(* a 2)
(* b 3)))