branch: elpa/llama
commit 2a353789261767c0f5cdfc9408384e96ea10912a
Author: Jonas Bernoulli <jo...@bernoul.li>
Commit: Jonas Bernoulli <jo...@bernoul.li>

    ##: Completely separate handling of rest arguments
---
 llama.el | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/llama.el b/llama.el
index 9ec5d3e3a7..f31208955d 100644
--- a/llama.el
+++ b/llama.el
@@ -107,6 +107,8 @@ It also looks a bit like #\\='function."
     (signal 'wrong-type-argument (list 'symbolp fn)))
   (let* ((args (make-vector 10 nil))
          (body (llama--collect body args))
+         (rest (aref args 0))
+         (args (nreverse (cdr (append args nil))))
          (pos  0)
          (opt  nil))
     `(lambda
@@ -122,19 +124,16 @@ It also looks a bit like #\\='function."
                 (when opt
                   (error "`%s' cannot follow optional arguments" symbol))
                 (list symbol))
-               ((memq symbol '(&* _&*))
-                (list '&rest symbol))
                (opt
                 (list symbol))
                ((setq opt t)
                 (list '&optional symbol))))
-            (nconc (let (symbols)
-                     (dolist (symbol (nreverse (cdr (append args nil))))
-                       (when (or symbol symbols)
-                         (push symbol symbols)))
-                     symbols)
-                   (let ((rest (aref args 0)))
-                     (and rest (list rest)))))))
+            (let (symbols)
+              (dolist (symbol args)
+                (when (or symbol symbols)
+                  (push symbol symbols)))
+              symbols)))
+        ,@(and rest (list '&rest rest)))
        (,fn ,@body))))
 
 (defconst llama--unused-argument (make-symbol "llama--unused-argument"))

Reply via email to