functional programming

Moshe Zadka moshez at
Fri Feb 25 17:31:08 CET 2000

On Fri, 25 Feb 2000, Steve Holden wrote:

> I was thinking more of the need for stack traceback when errors were
> detected.  I agree that a call at the end of a try block is not a
> tail call.  I am just concerned that tail call optimization would lose
> important debugging context unless you substitute some mechanism which
> retains the required information, which would defeat the point of the
> optimization.  Uncaught exceptions are handled at main level, and
> need full dynamic context.
> Or have I missed something?

Yes: the definition of "full dynamic context".
You're not objecting that in

for i in range(10):
	if i>8:
		raise ValueError()

The dynamic context does not include the context for i=0,...,8

But you do claim that in

def tail(n):
	if n>8:
		raise ValueError
	if n==10:
	return tail(n+1)

The dynamic context includes that for i=0,...,8


I will repeat my claim, that no one except someone expecting
tail-optimization does "return f(x)".

but-it-doesn't-mean-it's-worth-it-ly y'rs, Z.
Moshe Zadka <mzadka at>. 
INTERNET: Learn what you know.
Share what you don't.

More information about the Python-list mailing list