Reputation: 5242
As far as I can tell, Clojure's recur
is backed by the compiler whereas in other lisps it is implemented at a lower level.
As I read, this wouldn't be a "general" TCO. Aside from the obvious (a keyword + checking are needed), is in any way recur
less powerful?
Upvotes: 5
Views: 273
Reputation: 3919
recur
only supports tail-recursion optimization, which is a subclass of general TCO. Clojure also supports mutual or indirect recursion through trampoline
.
EDIT
Also, I think general TCO was expected to land in JVM with Java 7 and I've mixed that with Project Lambda's (adding closures in Java) schedulerecur
was meant as a temporary solution. Then Oracle happened.
Upvotes: 2
Reputation: 91554
recur differs slightly from full TCO in that recur
works with both loops and functions and does not do some of the things that a full implementation of TCO would. The philosophical backing for this is to make the special part look special as opposed to silently optimizing a uniform syntax.
Upvotes: 1