tail recursion questions

chris at seberino.org chris at seberino.org
Wed Jan 23 21:58:20 PST 2008


It appears recursion is nice but *iteration* takes up less space than
recursion?....

And tail recursion allows us to nest our recursion as insanely as we want
knowing that compiler/interpreter will convert it under the hood to
a for loop for us!?!??

I tried this in Python....

def f(x):
	print x,
	f(x)

It didn't go on forever but bombed with a "maximum recursion depth exceeded"
message.

If all the smart kids know about tail recursion then how come the Python
interpreter couldn't/didn't use tail recursion to prevent my infinite loop from
bombing?

Chris



More information about the KPLUG-LPSG mailing list