summaryrefslogtreecommitdiffstats
path: root/share/txr/stdlib/except.tl
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2017-01-29 08:16:59 -0800
committerKaz Kylheku <kaz@kylheku.com>2017-01-29 08:16:59 -0800
commit6cd69f064604b84d68add090b5d8aa69313672df (patch)
treee33f46247b8d19ff4cf9a5d9278a41a6e26bca3b /share/txr/stdlib/except.tl
parent1ddcfabd1b389bbf1512cf405a10dbde6efd8101 (diff)
downloadtxr-6cd69f064604b84d68add090b5d8aa69313672df.tar.gz
txr-6cd69f064604b84d68add090b5d8aa69313672df.tar.bz2
txr-6cd69f064604b84d68add090b5d8aa69313672df.zip
catch: expand param macros before inserting arg.
* share/txr/stdlib/except.tl (catch): Expand the parameters and body of each clause with sys:expand-params to get rid of parameter macros. Then insert the leftmost gensym. This now allows parameter macros to be used in cach clauses.
Diffstat (limited to 'share/txr/stdlib/except.tl')
-rw-r--r--share/txr/stdlib/except.tl7
1 files changed, 5 insertions, 2 deletions
diff --git a/share/txr/stdlib/except.tl b/share/txr/stdlib/except.tl
index 0f81e763..2fb21f9d 100644
--- a/share/txr/stdlib/except.tl
+++ b/share/txr/stdlib/except.tl
@@ -27,10 +27,13 @@
(defun sys:handle-bad-syntax (item)
(throwf 'eval-error "~s: bad clause syntax: ~s" 'handle item))
-(defmacro catch (:form form try-form . catch-clauses)
+(defmacro catch (:form form :env e try-form . catch-clauses)
(let ((catch-syms [mapcar car catch-clauses])
(sys-catch-clauses (mapcar (do mac-param-bind @1 (type args . body) @1
- ^(,type (,(gensym) ,*args) ,*body))
+ (tree-bind (args-ex . body-ex)
+ (sys:expand-params args body
+ e nil form)
+ ^(,type (,(gensym) ,*args-ex) ,*body-ex)))
catch-clauses)))
^(sys:catch ,catch-syms ,try-form ,*sys-catch-clauses)))