Add display-continuation.

This commit is contained in:
Martin Gasbichler 2003-04-23 09:21:30 +00:00
parent a061a2fa33
commit c7e5b8e20a
4 changed files with 44 additions and 4 deletions

View File

@ -84,3 +84,26 @@ Error: exception
(channel-maybe-write 32 '#{Byte-vector 10} 0 1 '#{Output-channel 4} ---) (channel-maybe-write 32 '#{Byte-vector 10} 0 1 '#{Output-channel 4} ---)
WARNING: Returning does not work from a scsh with a running REPL!!! WARNING: Returning does not work from a scsh with a running REPL!!!
(with-fatal-and-capturing-error-handler handler thunk)
An exception handler with allows to capture the continuation of the
exception. Here HANDLER is a procedure like
(handler condition continuation decline) -> val
CONDITION and DECLINE are the same as in the usual WITH-HANDLER
procedure. CONTINUATION represents the continuation of the
exception. However, this is not a procedure but the VM's continuation
object. The continuation of HANDLER is the continuation of
WITH-FATAL-AND-CAPTURING-ERROR-HANDLER.
(display-continuation continuation [port] -> unspecified
The procedural analogy to the ,proceed command. Continuation must be a
continuation object as captured by
WITH-FATAL-AND-CAPTURING-ERROR-HANDLER, not a procedure as captured by
CALL-WITH-CURRENT-CONTINUATION.

View File

@ -5,7 +5,7 @@
;;; the distribution. ;;; the distribution.
;; From SUnet plus one more call/cc to capture the continuation of the error ;; From SUnet plus one more call/cc to capture the continuation of the error
(define (with-fatal-and-capturing-error-handler* handler thunk) (define (with-fatal-and-capturing-error-handler handler thunk)
(call-with-current-continuation (call-with-current-continuation
(lambda (accept) (lambda (accept)
((call-with-current-continuation ((call-with-current-continuation
@ -23,7 +23,7 @@
(lambda () (call-with-values thunk accept))))))))) (lambda () (call-with-values thunk accept)))))))))
(define (with-inspecting-handler port prepare thunk) (define (with-inspecting-handler port prepare thunk)
(with-fatal-and-capturing-error-handler* (with-fatal-and-capturing-error-handler
(lambda (condition condition-continuation more) (lambda (condition condition-continuation more)
(with-handler (with-handler
(lambda (c2 m2) (lambda (c2 m2)
@ -37,3 +37,16 @@
(with-continuation condition-continuation (lambda () res))) (with-continuation condition-continuation (lambda () res)))
(more)))) (more))))
thunk)) thunk))
(define display-preview (eval 'display-preview
(rt-structure->environment (reify-structure 'debugging))))
(define (display-continuation continuation . maybe-port)
(let ((out (if (null? maybe-port)
(current-output-port)
(car maybe-port))))
(if continuation
(display-preview (continuation-preview continuation)
out)
(display 'bottom-contination out))))

View File

@ -3,7 +3,9 @@
remote-repl)) remote-repl))
(define-interface inspect-exception-interface (define-interface inspect-exception-interface
(export with-inspecting-handler)) (export with-inspecting-handler
with-fatal-and-capturing-error-handler
display-continuation))
(define-interface socket2stdports-interface (define-interface socket2stdports-interface
(export socket<->stdports)) (export socket<->stdports))

View File

@ -10,6 +10,8 @@
(define-structure inspect-exception inspect-exception-interface (define-structure inspect-exception inspect-exception-interface
(open scheme-with-scsh (open scheme-with-scsh
rt-modules
exceptions
conditions conditions
escapes escapes
handle handle