[plt-scheme] guido on tail recursion

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Fri Apr 24 16:15:38 EDT 2009

I think Eli meant to add that the call to the callback is in TP and  
that the call to loop in the callback is in TP and, by the TCO  
guarantee for Scheme, all of this (well-designed) code becomes a loop  
(from the perspective of space consumption) on the target machine --  

On Apr 24, 2009, at 3:57 PM, Eli Barzilay wrote:

> Here's a piece of code that I'm using now -- it's some gui thing, and
> for technical reasons, I'm implementing a `read-line' method that
> reads a line from the gui somehow.  Since the gui is on a single
> thread, I made `read-line' get a callback, which is called on the line
> when it has been read.  To play with my code I wrote a loop that reads
> lines in a loop:
>          (let loop ()
>            (output "Say something")
>            (read-line (lambda (line)
>                         (output (format "You said: ~a" line))
>                         (loop))))
> The thing is that the loop goes through the callback, so it doesn't
> translate to a simple (imperative) loop.  Is there a way to do this in
> python?
> (Looks like it shouldn't be hard, but I can't think of anything.  It
> might be that I'm blinded by scheme, or it might be the result of
> sleep deprivation...)
> -- 
>           ((lambda (x) (x x)) (lambda (x) (x x)))          Eli  
> Barzilay:
>                   http://www.barzilay.org/                 Maze is  
> Life!
> _________________________________________________
>   For list-related administrative tasks:
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme

Posted on the users mailing list.