12 lines
715 B
Common Lisp
12 lines
715 B
Common Lisp
(in-package #:user-side-compiler/toolkit)
|
|
|
|
(defmacro define-simple-print-object ((class &rest slot-names)
|
|
&key (format-string "~A")
|
|
(type t) (identity t))
|
|
(when (some #'listp slot-names)
|
|
(error "SLOT-NAMES must be a list of symbols, they may not be quoted."))
|
|
`(defmethod print-object ((object ,class) stream)
|
|
(print-unreadable-object (object stream :type ,type :identity ,identity)
|
|
(when (and ,@(loop :for s :in slot-names :collect `(slot-boundp object ',s)))
|
|
(format stream ,format-string ,@(loop :for s :in slot-names
|
|
:collect `(slot-value object ',s)))))))
|