Teaching : Python, Scheme, Java...

Jean-Paul Roy roy at unice.fr
Fri Apr 18 04:14:57 EDT 2003


In article <mailman.1050609281.18019.python-list at python.org>,
 Ian Bicking <ianb at colorstudy.com> wrote:

> On Thu, 2003-04-17 at 02:55, Jean-Paul Roy wrote:
> > - Python is bad : tail recursion is not iterative (also astonished at 
> > that, I can understand with an interpreter, but compiler ?)
> 
> Some would argue that tail recursion is not good for teaching and
> understanding, because you loose the call stack.  In the likely event of
> a traceback, it can be very confusing if you don't fully indicate how
> you got there, or if points upon the path were lost in an optimization.

That's a point, but in that case it would suffice to enveloppe the call 
by an identity function...
Let me cite the Normalization Report on Scheme:

"Programming languages should be designed not by piling feature on top 
of feature, but by removing the weaknesses and restrictions that make 
additional features appear necessary."

And so the wile or for... loops could be defined in Python as in Scheme 
with the tail recursion optimzation.
In the same spirit as Paul Graham's invited talk at PyCon'2003.

My teaching experience is that students knowing loops through the while 
construct actually *understand* the concept of iteration when they see 
that it is modelized by a tail recursive function which transforms a 
"vector of loop variables" (a state vector). Then, it is only a GOTO 
which passes arguments. I'm really happy to teach that way.

     -jpr




More information about the Python-list mailing list