[parenscript-devel] [PATCH] Extend CHAIN to support slot-values

Daniel White daniel at whitehouse.id.au
Fri Sep 11 05:33:42 UTC 2009


For example:
(chain ($ "foo") (bar x z) frob (baz 5) =>
  $('foo').bar(x, z).frob.baz(5);
---
 src/lib/ps-macro-lib.lisp |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/src/lib/ps-macro-lib.lisp b/src/lib/ps-macro-lib.lisp
index be90b79..2ef7d82 100644
--- a/src/lib/ps-macro-lib.lisp
+++ b/src/lib/ps-macro-lib.lisp
@@ -84,7 +84,9 @@
 (defpsmacro chain (&rest method-calls)
   (labels ((do-chain (method-calls)
              (if (cdr method-calls)
-                 `((@ ,(do-chain (cdr method-calls)) ,(caar method-calls)) ,@(cdar method-calls))
+                 (if (listp (car method-calls))
+                     `((@ ,(do-chain (cdr method-calls)) ,(caar method-calls)) ,@(cdar method-calls))
+                     `(@ ,(do-chain (cdr method-calls)) ,(car method-calls)))
                  (car method-calls))))
     (do-chain (reverse method-calls))))
 
-- 
1.6.4.2




More information about the parenscript-devel mailing list