From 41492dbe528403cd07b5e8d94d9a28afbd38ef88 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Sun, 29 Jan 2017 08:16:59 -0800 Subject: 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. --- share/txr/stdlib/except.tl | 7 +++++-- 1 file 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))) -- cgit v1.2.3