Am 02.05.15 um 11:58 schrieb Marko Rauhamaa:
Chris Angelico <ros...@gmail.com>:

Guido is against anything that disrupts tracebacks, and optimizing
tail recursion while maintaining traceback integrity is rather harder.

Tail recursion could be suppressed during debugging. Optimized code can
play all kinds of non-obvious tricks with the execution frame.

In the situations where it really is simple, you can always make the
change in your own code anyway. Often, the process of converting
recursion into tail recursion warps the code to the point where it's
abusing recursion to implement iteration anyway, so just make it
iterative.

While you shouldn't actively replace Python iteration with recursion, I
strongly disagree that naturally occurring tail recursion is abuse or
should be avoided in any manner.

Could you show me an example of naturally occuring tail recursion? I can't think of any. Or is it maybe one involving mutual recursion?

I need to add, I grew up with imperative programming, and as such got recursion as the solution to problems that are too complex for iteration, i.e. tree traversal and such, and exactly these are never tail-recursive.


        Christian
--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to