Recursive calls and stack
Gabriel Genellina
gagsl-py at yahoo.com.ar
Wed Feb 14 20:36:26 EST 2007
En Wed, 14 Feb 2007 10:41:53 -0300, Neil Cerutti <horpner at yahoo.com>
escribió:
> On 2007-02-14, Gabriel Genellina <gagsl-py at yahoo.com.ar> wrote:
>> Python does not do "tail recursion optimization" (at
>> least, I'm not aware of that).
>
> To be just a little pedantic, it's "tail call optimization". Any
> tail call can be optimized, not just recursive ones.
Maybe, but I didn't invent the term:
http://computing-dictionary.thefreedictionary.com/tail%20recursion%20optimisation
It's true that tail recursion is a special case of tail call - but it's
just the case that can be managed by hand, no special support on the
language -trampoline or whatever- is required (just a loop, "GOTO 1").
>> But even if it could do that, in this case you have recursive
>> calls between two functions, and that's a bit harder.
>
> So the effect is that mutual recursion isn't actually any harder.
But some kind of language support is required in this case. At least I
don't know how to handle mutual recursion (apart from inlining one
function inside the other...). But I'm certainly not a "program
transformation guru" (neither a novice!) so I would not be surprised if
someone says it can be done...
--
Gabriel Genellina
More information about the Python-list
mailing list