[plt-scheme] guido on tail recursion

From: Eli Barzilay (eli at barzilay.org)
Date: Fri Apr 24 15:57:07 EDT 2009

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))

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

(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!

Posted on the users mailing list.