[Python-Dev] Tail recursion

Delaney, Timothy C (Timothy) tdelaney at avaya.com
Mon Nov 24 15:54:15 EST 2003


> From: Guido van Rossum
> 
> But I have a problem with tail recursion.  It's generally requested by
> new converts from the Scheme/Lisp or functional programming world, and
> it usually means they haven't figured out yet how to write code
> without using recursion for everything yet.  IOW I'm doubtful on how
> much of a difference it would make for real Python programs (which,
> simplifying a bit, tend to use loops instead of recursion).  And also
> note that even if an exception is not caught, you'd like to see all
> stack frames listed when the traceback is printed or when the debugger
> is invoked.

However, that doesn't preclude it from being a thesis subject - in some ways it's actually a bonus as it encourages exploration as it's a direction that is *not* going to be explored by the language designer.

It's possible that we could see some truly unexpected benefits come out of this - or there could be no benefits to Python whatsoever.

However, from a purely academic point of view, I think it would be a quite reasonable thesis. It allows applying a well-explorered field of research to a new arena.

Besides ... sometimes a recursive solution is truly beautiful. Although I think in many (most?) cases a loop on a generator is probably the most appropriate and elegant approach.

Tim Delaney



More information about the Python-Dev mailing list