diff --git a/CHANGELOG.md b/CHANGELOG.md index 124b1176..ffb38f80 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -36,6 +36,7 @@ Features - Updated the garbage collector to enhance performance for programs with a high allocation rate, and to scale better to multiple concurrent threads. - Improved error handling by `display` and `write`. - Removed the `make_int` C macro which was deprecated and could cause problems when used in FFI functions. +- Added a `with-handler` exception handler form based on the syntax from Bigloo. Bug Fixes diff --git a/docs/api/scheme/base.md b/docs/api/scheme/base.md index 1d6d5697..0d9f562c 100644 --- a/docs/api/scheme/base.md +++ b/docs/api/scheme/base.md @@ -152,6 +152,7 @@ For more information see the [R7RS Scheme Specification](../../r7rs.p - [`vector-map`](#vector-map) - [`when`](#when) - [`with-exception-handler`](#with-exception-handler) +- [`with-handler`](#with-handler) - [`write-char`](#write-char) - [`write-string`](#write-string) - [`zero?`](#zero) @@ -1107,6 +1108,10 @@ Semantics: The `test` is evaluated, and if it evaluates to a true value, the exp (with-exception-handler handler thunk) +# with-handler + + (with-handler handler body) + # write-char (write-char char) diff --git a/scheme/base.sld b/scheme/base.sld index 0a398879..0ccd53d2 100644 --- a/scheme/base.sld +++ b/scheme/base.sld @@ -987,8 +987,7 @@ (lambda (k) (with-exception-handler (lambda (obj) - (,(cadr exp) obj) - (k #t)) + (k (,(cadr exp) obj))) (lambda () ,@(cddr exp)))))))) (define (with-exception-handler handler thunk)