One more call/cc for WITH-FATAL-AND-CAPTURING-ERROR-HANDLER: capture

the continuation of the handler and re-install it when the REPL
returns. Previously we only re-installed the raw-continuation which
lacks the dynamic environment.
This commit is contained in:
Martin Gasbichler 2005-05-27 08:10:37 +00:00
parent 8e592025e1
commit 9fc600512c
5 changed files with 37 additions and 25 deletions

View File

@ -1 +1 @@
Copyright (c) 2003 Martin Gasbichler
Copyright (c) 2003,2005 Martin Gasbichler

View File

@ -1,3 +1,12 @@
version 0.3
* Handler of WITH-FATAL-AND-CAPTURING-ERROR-HANDLER also receives the
continuation of the handler as a procedure
* Continuation and its dynamic environment is re-installed after exit of remote
REPL
version 0.2
* ???
version 0.1
* New package system.
* New structure GC in interaction

View File

@ -116,19 +116,19 @@ WARNING: Returning does not work from a scsh with a running REPL!!!
An exception handler with allows to capture the continuation of the
exception. Here HANDLER is a procedure like
(handler condition continuation decline) -> val
(handler condition raw-continuation condition 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.
procedure. RAW-CONTINUATION and CONTIUNATION represent the
continuation of the exception. RAW-CONTINUATION 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
(display-continuation raw-continuation [port] -> unspecified
The procedural analogy to the ,proceed command. Continuation must be a
continuation object as captured by
raw continuation object as captured by
WITH-FATAL-AND-CAPTURING-ERROR-HANDLER, not a procedure as captured by
CALL-WITH-CURRENT-CONTINUATION.

View File

@ -10,31 +10,34 @@
(lambda (accept)
((call-with-current-continuation
(lambda (k)
(with-handler
(lambda (condition more)
(primitive-cwcc
(lambda (condition-continuation)
(if (error? condition)
(call-with-current-continuation
(lambda (decline)
(k (lambda ()
(handler condition condition-continuation decline))))))
(more)))) ; Keep looking for a handler.
(lambda () (call-with-values thunk accept)))))))))
(with-handler
(lambda (condition more)
(primitive-cwcc
(lambda (raw-condition-continuation)
(call-with-current-continuation
(lambda (condition-continuation)
(call-with-current-continuation
(lambda (decline)
(k (lambda ()
(handler condition raw-condition-continuation
condition-continuation decline)))))
(more)))))) ; Keep looking for a handler.
(lambda () (call-with-values thunk accept)))))))))
(define (with-inspecting-handler port prepare thunk)
(with-fatal-and-capturing-error-handler
(lambda (condition condition-continuation more)
(lambda (condition raw-condition-continuation condition-continuation more)
(with-handler
(lambda (c2 m2)
(lambda (condition-continuation ignore)
(more))
(if (prepare condition)
(let ((res
(remote-repl "Welcome to the command processor of the remote scsh"
condition-continuation
raw-condition-continuation
port)))
;; TODO: option to return to continuation of handler (by leaving out the with-continuation)
(with-continuation condition-continuation (lambda () res)))
;; TODO: option to return to continuation of handler
;; (by leaving out this call)
(condition-continuation res))
(more))))
thunk))

View File

@ -1,5 +1,5 @@
(define-package "interaction"
(0 2)
(0 3)
((install-lib-version (1 0)))
(write-to-load-script
`((config)