aboutsummaryrefslogtreecommitdiff
path: root/lib/util.lisp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/util.lisp')
-rw-r--r--lib/util.lisp22
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/util.lisp b/lib/util.lisp
index 27f389e..4b827f1 100644
--- a/lib/util.lisp
+++ b/lib/util.lisp
@@ -70,3 +70,25 @@ determined by EXECUTABLE-ON-SYSTEM-P."
"Returns the strings \"true\" or \"false\" depending on whehter or not WHAT is null"
(if what "true" "false"))
+
+(defmacro defplist (name &rest slots)
+ (let* ((slots-names
+ (loop for slot in slots
+ when (symbolp slot)
+ collect slot
+ when (consp slot)
+ collect (first slot)))
+ (slot-defuns
+ (loop for slot in slots-names
+ collect `(defun ,(intern (format nil "~a-~a" name slot)) (,name)
+ (getf ,name ,(a:make-keyword slot)))
+ collect `(defun (setf ,(intern (format nil "~a-~a" name slot))) (val ,name)
+ (setf (getf ,name ,(a:make-keyword slot)) val))))
+ (make-name-defun
+ `(defun ,(intern (format nil "MAKE-~a" name)) (&key ,@slots)
+ (list ,@(loop for slot in slots-names
+ collect (a:make-keyword slot)
+ collect slot)))))
+ `(progn
+ ,make-name-defun
+ ,@slot-defuns)))