Concrete Proposal: while ... and while ...

Greg Ewing greg.ewing at compaq.com
Tue Jun 1 00:44:13 EDT 1999


Terry Reedy wrote:
> 
> Guido recently explained that the interpreter cannot assume that the inner
> call to a recursive function actually calls the function within which it
> sits.

But that's not required in order to do tail recursion.
All you need to do is recognise when you're about to call
a function and then immediately return, and either re-use
the current stack frame or pop the current one before
pushing a new one.

Python could probably do tbis without much difficulty,
as long as the called function is a Python function.
If it's a C function, though, things would get rather
tricky!

I'm not very worried about this personally, since I'm
quite happy to use iteration instead of recursion when
the language encourages it, as Python does with its
lovely for: loop.

Greg




More information about the Python-list mailing list