mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-07-07 13:16:36 +02:00
Alternate guard form - evaluate the guard clauses in the continuation of the raise.
We need to override the current-exception-handler and still pass a thunk to be applied on return, but this allows us to print stack traces inside guards.
This commit is contained in:
parent
af8aed4c5a
commit
0f723c17ea
1 changed files with 20 additions and 16 deletions
|
@ -923,22 +923,26 @@
|
|||
(define-syntax guard
|
||||
(syntax-rules ()
|
||||
((guard (var clause ...) e1 e2 ...)
|
||||
(let ((orig-handler (current-exception-handler)))
|
||||
((call-with-current-continuation
|
||||
(lambda (guard-k)
|
||||
(with-exception-handler
|
||||
(lambda (condition)
|
||||
((call-with-current-continuation
|
||||
(lambda (handler-k)
|
||||
(guard-k
|
||||
(let* ((var condition) ; clauses may set! var
|
||||
(res
|
||||
(with-exception-handler
|
||||
orig-handler
|
||||
(lambda ()
|
||||
(let ((var condition))
|
||||
(guard-aux (handler-k (lambda ()
|
||||
(guard-aux
|
||||
(handler-k (lambda ()
|
||||
(raise-continuable condition)))
|
||||
clause ...))))))))
|
||||
clause ...)))))
|
||||
(guard-k (lambda () res)))))))
|
||||
(lambda ()
|
||||
(call-with-values (lambda () e1 e2 ...)
|
||||
(lambda args
|
||||
(guard-k (lambda () (apply values args)))))))))))))
|
||||
(let ((res (begin e1 e2 ...)))
|
||||
(guard-k (lambda () res))))))))))))
|
||||
|
||||
(define-syntax guard-aux
|
||||
(syntax-rules (else =>)
|
||||
|
|
Loading…
Add table
Reference in a new issue