On Mon, 2008-01-14 at 18:25 +0000, David Rush wrote:
> Hi y'all -
...
> It may also be useful as a model for writing other sorts of error/exit
> handlers. Code is below the fold...
>
> david rush
Here is a parsimonious pearl for non-batch, REPL work, which I suspect
is full of unintended consequences and land mines but is working so
far ...
(library
(rl3 env debug)
(export debug-enable)
(import (rnrs base)
(only (rnrs io simple)
display)
(only (rnrs control)
unless)
(primitives call-with-output-string decode-error error-handler
reset))
(define simple-error-handler
(lambda e
(display (call-with-output-string
(lambda (sp) (decode-error e sp))))
(reset)))
(define default-error-handler #f)
(define debug-enable
(lambda (state)
(if state
(error-handler default-error-handler)
(error-handler simple-error-handler))))
(unless default-error-handler
(set! default-error-handler (error-handler))))
=====================================================
Larceny v0.961 "Fluoridation" (Jan 13 2008 08:39:06,
precise:Linux:unified)
larceny.heap, built on Sat Dec 29 17:39:47 EST 2007
ERR5RS mode (no libraries have been imported)
> (import (rnrs base))
> (import (rl3 env debug))
Autoloading (rl3 env debug)
Autoloading (rnrs control)
> (define x 3)
> (x x)
Error: Attempt to apply 3, which is not a procedure.
Entering debugger; type "?" for help.
debug> #<EOF>
> (debug-enable #f)
#f
> (x x)
Error: Attempt to apply 3, which is not a procedure.
> (string-ref "ray" 10)
Error: string-ref: 10 is not a valid index into string
> (debug-enable #t)
#t
> (string-ref "ray" 10)
Error: string-ref: 10 is not a valid index into string
Entering debugger; type "?" for help.
debug> #<EOF>
For the full stack trace as well as the error message without entering
the debugger, use David's posted code with (reset) in lieu of
(exit ...).
_______________________________________________
Larceny-users mailing list
[email protected]
https://lists.ccs.neu.edu/bin/listinfo/larceny-users