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:
parent
8e592025e1
commit
9fc600512c
scsh/interaction
|
@ -1 +1 @@
|
||||||
Copyright (c) 2003 Martin Gasbichler
|
Copyright (c) 2003,2005 Martin Gasbichler
|
||||||
|
|
|
@ -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
|
version 0.1
|
||||||
* New package system.
|
* New package system.
|
||||||
* New structure GC in interaction
|
* New structure GC in interaction
|
||||||
|
|
|
@ -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
|
An exception handler with allows to capture the continuation of the
|
||||||
exception. Here HANDLER is a procedure like
|
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
|
CONDITION and DECLINE are the same as in the usual WITH-HANDLER
|
||||||
procedure. CONTINUATION represents the continuation of the
|
procedure. RAW-CONTINUATION and CONTIUNATION represent the
|
||||||
exception. However, this is not a procedure but the VM's continuation
|
continuation of the exception. RAW-CONTINUATION is not a procedure but
|
||||||
object. The continuation of HANDLER is the continuation of
|
the VM's continuation object. The continuation of HANDLER is the
|
||||||
WITH-FATAL-AND-CAPTURING-ERROR-HANDLER.
|
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
|
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
|
WITH-FATAL-AND-CAPTURING-ERROR-HANDLER, not a procedure as captured by
|
||||||
CALL-WITH-CURRENT-CONTINUATION.
|
CALL-WITH-CURRENT-CONTINUATION.
|
||||||
|
|
||||||
|
|
|
@ -10,31 +10,34 @@
|
||||||
(lambda (accept)
|
(lambda (accept)
|
||||||
((call-with-current-continuation
|
((call-with-current-continuation
|
||||||
(lambda (k)
|
(lambda (k)
|
||||||
(with-handler
|
(with-handler
|
||||||
(lambda (condition more)
|
(lambda (condition more)
|
||||||
(primitive-cwcc
|
(primitive-cwcc
|
||||||
(lambda (condition-continuation)
|
(lambda (raw-condition-continuation)
|
||||||
(if (error? condition)
|
(call-with-current-continuation
|
||||||
(call-with-current-continuation
|
(lambda (condition-continuation)
|
||||||
(lambda (decline)
|
(call-with-current-continuation
|
||||||
(k (lambda ()
|
(lambda (decline)
|
||||||
(handler condition condition-continuation decline))))))
|
(k (lambda ()
|
||||||
(more)))) ; Keep looking for a handler.
|
(handler condition raw-condition-continuation
|
||||||
(lambda () (call-with-values thunk accept)))))))))
|
condition-continuation decline)))))
|
||||||
|
(more)))))) ; Keep looking for a handler.
|
||||||
|
(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 raw-condition-continuation condition-continuation more)
|
||||||
(with-handler
|
(with-handler
|
||||||
(lambda (c2 m2)
|
(lambda (condition-continuation ignore)
|
||||||
(more))
|
(more))
|
||||||
(if (prepare condition)
|
(if (prepare condition)
|
||||||
(let ((res
|
(let ((res
|
||||||
(remote-repl "Welcome to the command processor of the remote scsh"
|
(remote-repl "Welcome to the command processor of the remote scsh"
|
||||||
condition-continuation
|
raw-condition-continuation
|
||||||
port)))
|
port)))
|
||||||
;; TODO: option to return to continuation of handler (by leaving out the with-continuation)
|
;; TODO: option to return to continuation of handler
|
||||||
(with-continuation condition-continuation (lambda () res)))
|
;; (by leaving out this call)
|
||||||
|
(condition-continuation res))
|
||||||
(more))))
|
(more))))
|
||||||
thunk))
|
thunk))
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
(define-package "interaction"
|
(define-package "interaction"
|
||||||
(0 2)
|
(0 3)
|
||||||
((install-lib-version (1 0)))
|
((install-lib-version (1 0)))
|
||||||
(write-to-load-script
|
(write-to-load-script
|
||||||
`((config)
|
`((config)
|
||||||
|
|
Loading…
Reference in New Issue