From: Mark Wooding Date: Wed, 21 Oct 2015 23:29:58 +0000 (+0100) Subject: mdw-base.lisp: Allow multiple arguments in `update-place' etc. X-Git-Url: https://git.distorted.org.uk/~mdw/lisp/commitdiff_plain/53ccd04251004c520ab714e8ffc5b80f40536459 mdw-base.lisp: Allow multiple arguments in `update-place' etc. There doesn't seem to be a reason to require exactly one argument. So don't. --- diff --git a/mdw-base.lisp b/mdw-base.lisp index ab1a47c..ec86987 100644 --- a/mdw-base.lisp +++ b/mdw-base.lisp @@ -345,17 +345,17 @@ ;;;-------------------------------------------------------------------------- ;;; 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))