I really want to tell you all about this.
(defclass fourth-grader () ((teacher :initarg :teacher :initform "Mrs. Marple" :accessor fourth-grade-teacher) (name :initarg :name :reader name) (school :initarg :school :initform "Lawrence School" :accessor school) (age :initarg :age :initform 9 :accessor age)))
(defparameter *my-slots* (make-hash-table)
(defmacro in (class var &rest body)
`(with-slots ,(gethash class *my-slots*) ,var
,@body))
(defmacro defclass* (class parents &rest slots)
(labels ((worker (slot)
(if (atom slot)
(prim slot nil)
(prim (first slot) (second slot))))
(prim (slot init)
(push slot (gethash class *my-slots*))
(defslot* class slot init)))
`(defclass ,class ,parents ,(mapcar #'worker slots))))
(defun defslot* (class slot init)
`(,slot :initarg ,(intern (up slot) "KEYWORD")
:initform ,init
:accessor ,(intern (up class '- slot))))
(defun up (&rest all)
(with-output-to-string (s)
(dolist (one all)
(format s "~:@(~a~)" one))))
In action
(defclass* 4grade () name (age 9) (teacher "msrs marple") (school "lawrnce"))
(defun xxx (self b c)
(in 4grade self
(incf age (+ b c))
age))