5 ms·
> Then it argues that tail call optimisation is bad! I didn't think I'd find this, so I went digging. Sure enough: The disadvantage of tail recursion is tha
by mrkeen 2y ago
> Then it argues that tail call optimisation is bad!
I didn't think I'd find this, so I went digging. Sure enough:
The disadvantage of tail recursion is that it requires rearranging your recursive function so that the last action is returning the recursive call’s return value. This can make our recursive code even more unreadable.
Tail recursive functions require rearranging their code to make them suitable for the tail call optimization feature of the compiler or interpreter.
Personally, I take the stance that the tail recursion technique should never be used.
What can one do, but just disagree I guess?
> And what is the purpose of the book?
To straw-man functional programming with a one-two punch of "I already have that" and "it's bad" so devs never leave Python/JS land to find this stuff out for themselves ;)
- tpoacher 2y agoYep. Especially when a tail recursion can be immediately converted to an equivalent loop by definition (and vice versa). A bizzare comment at best, from someone writing a book on recursion.