You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

14 lines
630 B

(defun print-object-readably (object)
(let ((slots (map 'list #'c2mop:slot-definition-name (c2mop:class-slots (class-of object))))
(class (class-name (class-of object))))
(cons class (remove-if #'null
(loop for slot in slots
collect (if (slot-boundp object slot)
(cons slot (slot-value object slot))))))))
(defun read-object (sexp)
(let* ((class (car sexp))
(object (make-instance class)))
(loop for slot in (cdr sexp)
do (setf (slot-value object (car slot)) (cdr slot)))
object))