PEP 255: Simple Generators
eppstein at ics.uci.edu
Thu Jun 21 11:49:25 EDT 2001
In article <3B3181D1.BFB73057 at cosc.canterbury.ac.nz>,
Greg Ewing <greg at cosc.canterbury.ac.nz> wrote:
> Your proposal might work in the case where the recursion
> involved is tail-recursion, but using tail-recursion in
> place of iteration is a functional idiom that doesn't fit
> very well in Python, IMO.
I'm sorry, this was a little too densely packed for me, could you expand
it? Why is tail recursion somehow unPythonlike? Or, more to the point,
why should it remain that way? If it's merely that it is implemented
inefficiently (i.e. piling up unnecessary stack frames) then that can be
fixed, no? And anyway we were discussing a situation (PEP255) where stack
frames are not really at issue.
I have been using Python a very short time, but one thing I like very much
about it is its spirit of allowing all sorts of programming idioms -- it
doesn't force object orientation etc down your throat but it allows you to
write each program the way it makes the most sense. If a program makes the
most sense tail-recursively, why should that be discouraged?
David Eppstein UC Irvine Dept. of Information & Computer Science
eppstein at ics.uci.edu http://www.ics.uci.edu/~eppstein/
More information about the Python-list