mirror of
https://github.com/justinethier/cyclone.git
synced 2025-07-11 06:47:37 +02:00
Added (with-exception-handler)
This commit is contained in:
parent
86b6c0964e
commit
cc75d7b44c
1 changed files with 13 additions and 2 deletions
15
trans.scm
15
trans.scm
|
@ -69,8 +69,19 @@
|
|||
(foldr (lambda (x y) (cons (func x) y)) '() lst))
|
||||
(define (not x) (if x #f #t))
|
||||
(define (reverse lst) (foldl cons '() lst))
|
||||
; (define (with-exception-handler handler thunk)
|
||||
;
|
||||
(define (with-exception-handler handler thunk)
|
||||
(let ((my-handler
|
||||
(lambda (obj)
|
||||
;; Unregister this handler since it is no longer needed
|
||||
(Cyc-remove-exception-handler)
|
||||
(handler obj) ;; Actual handler
|
||||
(error "exception handler returned"))))
|
||||
;; 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)
|
||||
;; Only reached if no ex raised
|
||||
(Cyc-remove-exception-handler)))
|
||||
))
|
||||
|
||||
;; Built-in macros
|
||||
|
|
Loading…
Add table
Reference in a new issue