diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2017-01-29 08:16:59 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2017-01-29 08:16:59 -0800 |
commit | 41492dbe528403cd07b5e8d94d9a28afbd38ef88 (patch) | |
tree | e33f46247b8d19ff4cf9a5d9278a41a6e26bca3b | |
parent | 4b632902a9235bd5feb551e67c1b386b600ba830 (diff) | |
download | txr-41492dbe528403cd07b5e8d94d9a28afbd38ef88.tar.gz txr-41492dbe528403cd07b5e8d94d9a28afbd38ef88.tar.bz2 txr-41492dbe528403cd07b5e8d94d9a28afbd38ef88.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.
-rw-r--r-- | share/txr/stdlib/except.tl | 7 |
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))) |