The compiler does not optimize the function . It optimizes the call for this function. It can be a call to the same function inside it, it can be a call to another function, it does not matter.
... this is not the case with Clojure, where it recurcan return execution only to the last "recursive point" (be it loopeither fn), which makes mutual recursion impossible without "outside help", for example trampoline . It looks more like a gang than a solution, but the problem is too big, and the right solution will require too much.
, , Elixir: tail call. .
, .
, .
Clojure , :
(defn x [] (x)) ; <- StackOverflowError if called
(defn x [] (recur)) ; <- hangs if called
, :
, .
, .