[plt-scheme] Stylistic (I hope!) question regarding driver loop

From: Gregory Woodhouse (gregory.woodhouse at sbcglobal.net)
Date: Sat Jan 21 14:31:24 EST 2006

I thought I might try experimenting with the "meta-circular"  
interpreter in SICP, perhaps implementing lazy evaluation rules or  
other language modifications. Well, I put together a little driver  
loop using letrec

       (lambda ()
           (display ">> ")
           (let ((input-exp (read)))
             (unless (equal? input-exp '(exit))
               (let ((the-value
                      (evaluate input-exp)))
                   (display the-value)
       (lambda (x) x)))

and it seems to work just fine. My first concern was that a construct  
like this would chew up stack space, but then I thought it was just  
tail recursion so it shouldn't matter. But then I wonder if placing a  
call to main-loop in the body of a letrec like that makes any  
difference. Is this safe? Is there a better way to write it?

Gregory Woodhouse
gregory.woodhouse at sbcglobal.net

"All truth passes through three stages: First, it is
ridiculed. Second, it is violently opposed. Third,
it is accepted as being self-evident."
--Arthur Schopenhaur

Posted on the users mailing list.