chiark / gitweb /
mdw-base.lisp: Allow multiple arguments in `update-place' etc.
authorMark Wooding <mdw@distorted.org.uk>
Wed, 21 Oct 2015 23:29:58 +0000 (00:29 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Wed, 21 Oct 2015 23:29:58 +0000 (00:29 +0100)
There doesn't seem to be a reason to require exactly one argument.  So
don't.

mdw-base.lisp

index ab1a47c1fad4b26fd38771c9d27fd66a195d3a5d..ec869871af64b302ec008ed61d60bd71f61a8d0e 100644 (file)
@@ -345,17 +345,17 @@ (defmacro with-places ((&key environment) places &body body)
 ;;;--------------------------------------------------------------------------
 ;;; Update-in-place macros built using with-places.
 
-(defmacro update-place (op place arg &environment env)
-  "Update PLACE with the value of OP PLACE ARG, returning the new value."
+(defmacro update-place (op place &rest args &environment env)
+  "Update PLACE with (OP PLACE . ARGS), returning the new value."
   (with-places (:environment env) (place)
-    `(setf ,place (,op ,place ,arg))))
+    `(setf ,place (,op ,place ,@args))))
 
-(defmacro update-place-after (op place arg &environment env)
-  "Update PLACE with the value of OP PLACE ARG, returning the old value."
+(defmacro update-place-after (op place &rest args &environment env)
+  "Update PLACE with (OP PLACE . ARGS), returning the old value."
   (with-places (:environment env) (place)
     (with-gensyms (x)
       `(let ((,x ,place))
-        (setf ,place (,op ,x ,arg))
+        (setf ,place (,op ,x ,@args))
         ,x))))
 
 (defmacro incf-after (place &optional (by 1))