From 8c8b7bff74ce4447dca0f34a88207cf78173d710 Mon Sep 17 00:00:00 2001 From: Justin Ethier Date: Thu, 19 Mar 2015 22:59:23 -0400 Subject: [PATCH] Fixes for raise-continuable --- test.scm | 4 ++-- trans.scm | 8 +++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/test.scm b/test.scm index a97c3116..358b569d 100644 --- a/test.scm +++ b/test.scm @@ -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 diff --git a/trans.scm b/trans.scm index ebbdea5c..686d59e0 100644 --- a/trans.scm +++ b/trans.scm @@ -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