[plt-scheme] EOPL language question - error handling

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Sun Mar 30 10:14:39 EDT 2008

At Fri, 28 Mar 2008 11:41:07 -0700, "Mark Engelberg" wrote:
> So, once you have a read-eval-print loop, one thing you might want to
> do is upon an error, print the error message, and then restart the
> read-eval-print loop.  I'm not sure how to do that.
> 
> Tried stuff like this:
> 
> (define read-eval-print
>   (sllgen:make-rep-loop "> " (lambda (pgm)(print (eval pgm)))
>                         (sllgen:make-stream-parser scanner grammar)))
> (define eopl:error-stop read-eval-print)
> 
> This eats the first error message and continues, but the second error
> message crashes you out of the repl and prints a double error message.
> 
> How to make this work?

Use a continuation with `eopl:error-stop':

 (define (repl-keep-going)
   (let loop ()
     ((call-with-current-continuation
       (lambda (esc)
         (set! eopl:error-stop (lambda ()
                                 (esc loop)))
         (read-eval-print)
         (lambda () 'done))))))


Matthew



Posted on the users mailing list.