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 ab1a47c..ec86987 100644 (file)
 ;;;--------------------------------------------------------------------------
 ;;; 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))