From c3b19b129a11f61ad6bbe17c04b6bff92c048f17 Mon Sep 17 00:00:00 2001 From: Olof-Joachim Frahm Date: Sat, 18 May 2013 00:47:05 +0200 Subject: [PATCH] Add and export PUSHNEW. --- src/boot.lisp | 15 +++++++++++++++ src/toplevel.lisp | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/boot.lisp b/src/boot.lisp index e33051c..4f22ec9 100644 --- a/src/boot.lisp +++ b/src/boot.lisp @@ -143,6 +143,21 @@ ,@(cdr newval)) ,setter)))) +(defmacro pushnew (x place &rest keys &key key test test-not) + (declare (ignore key test test-not)) + (multiple-value-bind (dummies vals newval setter getter) + (get-setf-expansion place) + (let ((g (gensym)) + (v (gensym))) + `(let* ((,g ,x) + ,@(mapcar #'list dummies vals) + ,@(cdr newval) + (,v ,getter)) + (if (member ,g ,v ,@keys) + ,v + (let ((,(car newval) (cons ,g ,getter))) + ,setter)))))) + (defmacro dolist ((var list &optional result) &body body) (let ((g!list (gensym))) (unless (symbolp var) (error "`~S' is not a symbol." var)) diff --git a/src/toplevel.lisp b/src/toplevel.lisp index 60e016a..c498c42 100644 --- a/src/toplevel.lisp +++ b/src/toplevel.lisp @@ -70,7 +70,7 @@ multiple-value-prog1 nconc nil ninth not nreconc nth nthcdr null numberp or otherwise package-name package-use-list packagep pairlis parse-integer plusp pop prin1-to-string print proclaim prog prog1 - prog2 progn psetq push quote rassoc read-from-string remove remove-if + prog2 progn psetq push pushnew quote rassoc read-from-string remove remove-if remove-if-not return return-from revappend reverse rplaca rplacd second set setf setq seventh sixth some string string-upcase string= string< stringp subseq subst symbol-function symbol-name symbol-package -- 1.7.10.4