common-lisp Obtain the slot names of a Class


Lets say we have a class as

(defclass person ()
  (name email age))

To obtain the names of the slots of the class we use the function class-slots. This can be found in the closer-mop package, provided by the closer-mop system. To load it the running lisp image we use (ql:quickload :closer-mop). We also have to make sure the class is finalized before calling class-slots.

(let ((class (find-class 'person)))
  (c2mop:ensure-finalized class)
  (c2mop:class-slots class))

which returns a list of effective slot definition objects: