Fixes for raise-continuable

This commit is contained in:
Justin Ethier 2015-03-19 22:59:23 -04:00
parent 1d5409b4ae
commit 8c8b7bff74
2 changed files with 7 additions and 5 deletions

View file

@ -34,8 +34,8 @@
(display "a warning has been issued")))
42)
(lambda ()
(+ (raise-continuable "should be a number")
23))))
(+ (raise-continuable "should be a number") 23)
)))
;prints: should be a number
;=> 65

View file

@ -74,7 +74,8 @@
(define (raise-continuable obj)
((Cyc-current-exception-handler) (list 'continuable obj)))
(define (with-exception-handler handler thunk)
(let ((my-handler
(let ((result #f)
(my-handler
(lambda (obj)
(let ((result #f)
(continuable? (and (pair? obj)
@ -89,9 +90,10 @@
;; TODO: cond-expand below, since it uses Cyc functions?
;; probably no need since this is part of internal lib
(Cyc-add-exception-handler my-handler)
(thunk)
(set! result (thunk))
;; Only reached if no ex raised
(Cyc-remove-exception-handler)))
(Cyc-remove-exception-handler)
result))
))
;; Built-in macros