Hard Light Productions Forums
Off-Topic Discussion => Programming => Topic started by: Polpolion on January 29, 2011, 03:59:52 pm
-
seriously **** that ****
why would even want to bother
it's really hard to implement in most cases even if you understand non-tail recursion, and it's STILL WORSE THAN NORMAL ITERATION
don't even care that it might prevent offbyone errors; in the time it takes to implement a tail recursive function, you could probably write the function iteratively and check it over for offbyone errors
seriously, what gives
-
The nice thing about tail recursion is, if you have a compiler that is optimizing it will transform the code into a non recursive iterative call. Which means that you get the advantages of readability that you get with recursion and without the overhead of recursion.
-
Used to use this a lot in Z80 because of limited CPU speed and stack-size, a jmp used less cycles than a jsr, so with iterative calls the savings used to be quite noticeable, and you didn't kill the stack.
-
I don't know about tail recursion specifically, but I do know that I found working with Scheme to be utter hell in the one class I took which used it, as the whole damn language is recursive. Ugh.
-
Really? :( They told us up front, "If you can get recursion, you'll be fine; if not, you're screwed," and soon I grew to love it.