From fe533f82ee26d0bf98468f25b263e8f8461f309e Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Fri, 8 Mar 2019 08:25:42 -0800 Subject: defset: support improper list places. * share/txr/stdlib/defset.tl (defset-expander): Check for restpar being an atom and handle differently. We still don't handle the case where (b . c) is matched against a rest parameter; in this case the mapcar will process an improper list. I.e. the improper form must have an atom which matches the position of the rest parameter. * txr.1: Updated. --- share/txr/stdlib/defset.tl | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'share') diff --git a/share/txr/stdlib/defset.tl b/share/txr/stdlib/defset.tl index 3fd8de2e..521260ba 100644 --- a/share/txr/stdlib/defset.tl +++ b/share/txr/stdlib/defset.tl @@ -67,10 +67,11 @@ (with-gensyms (getter setter) ^(defplace (,name ,*params) body (,getter ,setter - (let* ((gpf-pairs (append (mapcar (op list (gensym)) - (list ,*fixpars)))) + (let* ((gpf-pairs (mapcar (op list (gensym)) (list ,*fixpars))) (gpr-pairs (if ',restpar - (mapcar (op list (gensym)) ,restpar))) + (if (consp ,restpar) + (mapcar (op list (gensym)) ,restpar) + (list (list (gensym) ,restpar))))) (ext-pairs (mapcar (op list (gensym)) (list ,*extsyms))) (pgens [mapcar car gpf-pairs]) (rgens [mapcar car gpr-pairs]) @@ -81,7 +82,9 @@ ,*(zip ',extsyms (mapcar (ret ^',@1) egens)) ,*(if gpr-pairs - ^((,',restpar ',rgens)))) + (if (consp ,restpar) + ^((,',restpar ',rgens)) + ^((,',restpar ',(car rgens)))))) (macrolet ((,,getter () ,',getform) (,,setter (,',newval) ,',setform)) ,body)) -- cgit v1.2.3