;;; Possibly a tad naive, but... (defmacro post-incf (form &optional (increment 1)) (let ((value (gensym "POST-INCF"))) `(let ((,value ,form)) (prog1 ,value (setf ,form (+ ,value ,increment))))))
Ingvar ingvar@cathouse.bofh.se writes:
;;; Possibly a tad naive, but... (defmacro post-incf (form &optional (increment 1)) (let ((value (gensym "POST-INCF"))) `(let ((,value ,form)) (prog1 ,value (setf ,form (+ ,value ,increment))))))
;;; Possibly a tad less naive... (defmacro post-incf (form &optional (increment 1) &environment env) (with-gensyms (result) (multiple-value-bind (temps vals vars writer reader) (get-setf-expansion form env) `(let* (,@(mapcar #'list temps vals) (,result ,reader) (,(first vars) (+ ,result ,increment))) ,writer ,result))))