summaryrefslogtreecommitdiffstats
path: root/share/txr/stdlib/except.tl
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2017-01-25 10:57:12 -0800
committerKaz Kylheku <kaz@kylheku.com>2017-01-25 10:57:12 -0800
commitc485146a246ab4b69e6ec510ec47713897f4d463 (patch)
tree3e22b6ac0f756258851a0e280dac9aeb012931c9 /share/txr/stdlib/except.tl
parent41ea4bd2c8791696525aadb0a457ba36fa1d204e (diff)
downloadtxr-c485146a246ab4b69e6ec510ec47713897f4d463.tar.gz
txr-c485146a246ab4b69e6ec510ec47713897f4d463.tar.bz2
txr-c485146a246ab4b69e6ec510ec47713897f4d463.zip
New handle* macro, analogous to catch*.
* share/txr/stdlib/except.tl (sys:expand-handle): New function. (handle): Use sys:expand-handle to expand arguments. The previously unused :whole form argument is now put to use, and correctly captured using :form rather than :whole. (handle*): New macro. * txr.1: Documented.
Diffstat (limited to 'share/txr/stdlib/except.tl')
-rw-r--r--share/txr/stdlib/except.tl16
1 files changed, 12 insertions, 4 deletions
diff --git a/share/txr/stdlib/except.tl b/share/txr/stdlib/except.tl
index abba8bdb..0f81e763 100644
--- a/share/txr/stdlib/except.tl
+++ b/share/txr/stdlib/except.tl
@@ -38,8 +38,9 @@
(let ((catch-syms [mapcar car catch-clauses]))
^(sys:catch ,catch-syms ,try-form ,*catch-clauses)))
-(defmacro handle (:whole form try-form . handle-clauses)
- (let* ((exc-sym (gensym))
+(defun sys:expand-handle (form try-form handle-clauses)
+ (let* ((oper (car form))
+ (exc-sym (gensym))
(exc-args (gensym))
(syms-fragments (collect-each ((hc handle-clauses))
(tree-case hc
@@ -47,8 +48,9 @@
(unless (symbolp name)
(sys:handle-bad-syntax hc))
(list name ^(apply (lambda ,arglist ,*body)
- ,*(if (and (plusp sys:compat)
- (<= 161 sys:compat))
+ ,*(if (or (eq oper 'handle*)
+ (and (plusp sys:compat)
+ (<= 161 sys:compat)))
^(,exc-sym))
,exc-args)))
(else (sys:handle-bad-syntax hc))))))
@@ -59,5 +61,11 @@
,[mapcar car syms-fragments]
,try-form)))
+(defmacro handle (:form form try-form . handle-clauses)
+ (sys:expand-handle form try-form handle-clauses))
+
+(defmacro handle* (:form form try-form . handle-clauses)
+ (sys:expand-handle form try-form handle-clauses))
+
(defmacro ignwarn (. forms)
^(handler-bind (lambda (exc-sym arg) (throw 'continue)) (warning) ,*forms))