functional programming

Denys Duchier Denys.Duchier at ps.uni-sb.de
Fri Feb 25 06:23:20 EST 2000


"Tim Peters" <tim_one at email.msn.com> writes:

> It's tail-call *optimization* that's un-Pythonic, as it's a gimmick
> supported by only a handful of widely unused <0.5 wink> languages
> and surprising to people coming from anything else: damaging
> tracebacks would be Major Badness, much worse than the gain for the
> relative thimbleful of people who are uncomfortable coding loops
> etc.

Tim's opinion notwithstanding, it seems to me that the only technical
reason why tail call optimization _cannot_ (at least not easily) be
supported by python has to do with destructors for local objects.  The
expectation is that an object created locally and assigned to a local
variable has a dynamic extent that coincides with execution in its
scope.  The timely finalization achieved by reference counting means
that its destructor is invoked precisely when the scope is exited.
Tail call optimization would have to invoke it when the tail call is
made.

I cannot help but add that the derogatory comment concerning tail call
optimization is not only shortsighted, but also fallacious as it rests
entirely on proof by popularity according to which we should all eat
shit, since 50 trillion flies can't all be wrong.

-- 
Dr. Denys Duchier			Denys.Duchier at ps.uni-sb.de
Forschungsbereich Programmiersysteme	(Programming Systems Lab)
Universitaet des Saarlandes, Geb. 45	http://www.ps.uni-sb.de/~duchier
Postfach 15 11 50			Phone: +49 681 302 5618
66041 Saarbruecken, Germany		Fax:   +49 681 302 5615



More information about the Python-list mailing list