diff --git a/asd.lisp b/asd.lisp new file mode 100644 index 0000000..a11cc38 --- /dev/null +++ b/asd.lisp @@ -0,0 +1,31 @@ +(progn + (defun add (a b) (+ a b)) + (defvar whatever 16)) + +;; struct +(progn + (defun constructor-name (sym) + (intern (concatenate 'string "MAKE-" (string sym)))) + + (defun accessor-name (name sym) + (intern (concatenate 'string (string name) "-" (string sym)))) + + (defun setter-name (name sym) + (intern (concatenate 'string "SET-" (string name) "-" (string sym)))) + + (defmacro mydefstruct (name &rest slots) + `(progn + (defun ,(constructor-name name) + ,slots + (list ,@slots)) + ,@(loop for i from 0 to (1- (length slots)) collect + `(defun ,(accessor-name name (nth i slots)) + (instance) + (nth ,i instance))) + ,@ (loop for i from 0 to (1- (length slots)) collect + `(defun ,(setter-name name (nth i slots)) + (instance val) + (setf (nth ,i instance) val))) + ,@(loop for i from 0 to (1- (length slots)) collect + `(defsetf ,(accessor-name name (nth i slots)) + ,(setter-name name (nth i slots)))))))