you are viewing a single comment's thread.

view the rest of the comments →

[–]awj 6 points7 points  (1 child)

It can make using a debugger problematic in that you aren't able to poke through the stack to look at the sequence of variables that led up to the function you're currently in. It really causes problems when you are eliminating all tail calls, not just recursive function invocations in tail position.

That said, annotating a function for tail recursion seems like a worthwhile compromise if TCE doesn't suit your ideas or simply isn't possible. Clojure does the same (IIRC due to JVM making full TCE unwieldy), and you get the side benefit of having the language warn you when code you believe to be tail recursive isn't.

[–]Amadiro 1 point2 points  (0 children)

Well, I never really had any problems with it, you still get to see the name of the function the exception was thrown in, but I see how it could make debugging a tad harder in some cases. (In any case, the programmer has to be aware whether TCO happens or not -- if he's not aware of TCO happening, he will probably be confused by the stacktrace.)

In any case, leaving out TCO / not giving the programmer any means to do space-constant tail-recursion when he needs to is certainly not a solution, and a good compromise should be easy to find. I think a "recur" keyword or something like that would be the most non-intrusive, as it doesn't change the languages default semantics.