From b5ea0102bc06080b0ad3d0fa3bf11175c21a3380 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20V=C3=A1zquez?= Date: Thu, 25 Apr 2013 23:01:15 +0100 Subject: [PATCH] INCF and DECF work on proper places --- src/boot.lisp | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/boot.lisp b/src/boot.lisp index d57fa0b..0fc7a40 100644 --- a/src/boot.lisp +++ b/src/boot.lisp @@ -154,11 +154,25 @@ ;; Basic macros -(defmacro incf (x &optional (delta 1)) - `(setq ,x (+ ,x ,delta))) +(defmacro incf (place &optional (delta 1)) + (multiple-value-bind (dummies vals newval setter getter) + (get-setf-expansion place) + (let ((d (gensym))) + `(let* (,@(mapcar #'list dummies vals) + (,d ,delta) + (,(car newval) (+ ,getter ,d)) + ,@(cdr newval)) + ,setter)))) -(defmacro decf (x &optional (delta 1)) - `(setq ,x (- ,x ,delta))) +(defmacro decf (place &optional (delta 1)) + (multiple-value-bind (dummies vals newval setter getter) + (get-setf-expansion place) + (let ((d (gensym))) + `(let* (,@(mapcar #'list dummies vals) + (,d ,delta) + (,(car newval) (- ,getter ,d)) + ,@(cdr newval)) + ,setter)))) (defmacro push (x place) (multiple-value-bind (dummies vals newval setter getter) -- 1.7.10.4