3 ms·
Tail recursion optimization would be when the compiler on its own would recognize tail recursion calls and generate special code for that. That one needs to ma
by lispm 7y ago
Tail recursion optimization would be when the compiler on its own would recognize tail recursion calls and generate special code for that.
That one needs to manually annotate it in Clojure just means that the compiler is manually instructed to generate a loop-like construct instead of a function call.
The advantage in Clojure is that these loops are explicitly marked, which IMHO improves readablity.
Many Lisps don't bother to implement tail recursion optimization, because they support the more general tail call optimization - by adjusting/reusing the current stack frame and using a JMP instruction.