Teaching : Python, Scheme, Java...

Bengt Richter bokr at oz.net
Thu Apr 17 19:45:41 EDT 2003


On 17 Apr 2003 14:54:36 -0500, 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.
>
Or if the stack trace is so deep the first part scrolls away and you
give up waiting for the last part ;-)

Perphaps a trace output that would transform the traceback of, e.g.,

 >>> def recu(n):
 ...     if n>0: recu(n-1)
 ...     raise Exception, 'test'
 ...
 >>> recu(5)
 Traceback (most recent call last):
   File "<stdin>", line 1, in ?
   File "<stdin>", line 2, in recu
   File "<stdin>", line 2, in recu
   File "<stdin>", line 2, in recu
   File "<stdin>", line 2, in recu
   File "<stdin>", line 2, in recu
   File "<stdin>", line 3, in recu
 Exception: test

to

 Traceback (most recent call last):
   File "<stdin>", line 1, in ?
   File "<stdin>", line 2, in recu
 [ ... above 1 line repeated 4 more times ...]
   File "<stdin>", line 3, in recu
 Exception: test

or the like, could be handy?
And IWT short repeating cycles could be handled too.

Regards,
Bengt Richter




More information about the Python-list mailing list