From 9ae134ee00c94d622163df05439652167e7e3c54 Mon Sep 17 00:00:00 2001 From: Owen Rodley Date: Sat, 27 Apr 2013 10:03:43 +1200 Subject: [PATCH] Only evaluate place in POP once --- src/list.lisp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/list.lisp b/src/list.lisp index ddaeb56..0f95f42 100644 --- a/src/list.lisp +++ b/src/list.lisp @@ -56,7 +56,11 @@ (t tree))) (defmacro pop (place) - (let ((car-symbol (gensym))) - `(let ((,car-symbol (car ,place))) - (setf ,place (cdr ,place)) - ,car-symbol))) + (multiple-value-bind (dummies vals newval setter getter) + (get-setf-expansion place) + (let ((car-symbol (gensym))) + `(let* (,@(mapcar #'list dummies vals) + (,car-symbol (car ,getter)) + (,(car newval) (cdr ,getter))) + ,setter + ,car-symbol)))) -- 1.7.10.4