e389a847e003

Move gathering-vector destructuring into the macro lamda list

It's less code and it makes the arglist in slime nicer.
[view raw] [browse files]
author Steve Losh <steve@stevelosh.com>
date Mon, 31 Aug 2020 12:01:31 -0400
parents 1ca3e16900aa
children d6cc6af60002
branches/tags (none)
files src/control-flow.lisp

Changes

--- a/src/control-flow.lisp	Mon Jul 27 23:37:04 2020 -0400
+++ b/src/control-flow.lisp	Mon Aug 31 12:01:31 2020 -0400
@@ -181,7 +181,7 @@
         ,@body)
       (queue-contents ,result))))
 
-(defmacro gathering-vector (options &body body)
+(defmacro gathering-vector ((&key (size 16) (element-type t)) &body body)
   "Run `body` to gather some things and return a fresh vector of them.
 
   `body` will be executed with the symbol `gather` bound to a function of one
@@ -211,16 +211,14 @@
     #(1 2 3 a b)
 
   "
-  (destructuring-bind (&key (size 16) (element-type t))
-      options
-    (with-gensyms (result)
-      `(let ((,result (make-array ,size :adjustable t :fill-pointer 0
-                                  :element-type ,element-type)))
-         (flet ((gather (item)
-                  (vector-push-extend item ,result)
-                  item))
-           ,@body)
-         ,result))))
+  (with-gensyms (result)
+    `(let ((,result (make-array ,size :adjustable t :fill-pointer 0
+                      :element-type ,element-type)))
+       (flet ((gather (item)
+                (vector-push-extend item ,result)
+                item))
+         ,@body)
+       ,result)))
 
 
 (defmacro when-let (bindings &body body)