mirror of
https://github.com/justinethier/cyclone.git
synced 2025-05-24 20:45:06 +02:00
Fixes for raise-continuable
This commit is contained in:
parent
1d5409b4ae
commit
8c8b7bff74
2 changed files with 7 additions and 5 deletions
4
test.scm
4
test.scm
|
@ -34,8 +34,8 @@
|
||||||
(display "a warning has been issued")))
|
(display "a warning has been issued")))
|
||||||
42)
|
42)
|
||||||
(lambda ()
|
(lambda ()
|
||||||
(+ (raise-continuable "should be a number")
|
(+ (raise-continuable "should be a number") 23)
|
||||||
23))))
|
)))
|
||||||
;prints: should be a number
|
;prints: should be a number
|
||||||
;=> 65
|
;=> 65
|
||||||
|
|
||||||
|
|
|
@ -74,7 +74,8 @@
|
||||||
(define (raise-continuable obj)
|
(define (raise-continuable obj)
|
||||||
((Cyc-current-exception-handler) (list 'continuable obj)))
|
((Cyc-current-exception-handler) (list 'continuable obj)))
|
||||||
(define (with-exception-handler handler thunk)
|
(define (with-exception-handler handler thunk)
|
||||||
(let ((my-handler
|
(let ((result #f)
|
||||||
|
(my-handler
|
||||||
(lambda (obj)
|
(lambda (obj)
|
||||||
(let ((result #f)
|
(let ((result #f)
|
||||||
(continuable? (and (pair? obj)
|
(continuable? (and (pair? obj)
|
||||||
|
@ -89,9 +90,10 @@
|
||||||
;; TODO: cond-expand below, since it uses Cyc functions?
|
;; TODO: cond-expand below, since it uses Cyc functions?
|
||||||
;; probably no need since this is part of internal lib
|
;; probably no need since this is part of internal lib
|
||||||
(Cyc-add-exception-handler my-handler)
|
(Cyc-add-exception-handler my-handler)
|
||||||
(thunk)
|
(set! result (thunk))
|
||||||
;; Only reached if no ex raised
|
;; Only reached if no ex raised
|
||||||
(Cyc-remove-exception-handler)))
|
(Cyc-remove-exception-handler)
|
||||||
|
result))
|
||||||
))
|
))
|
||||||
|
|
||||||
;; Built-in macros
|
;; Built-in macros
|
||||||
|
|
Loading…
Add table
Reference in a new issue