Skip to content

Write macro for generating print-object methods #88

@alex-eg

Description

@alex-eg

Using closer-mop, do the following:

  1. Collect direct slots
  2. For each parent, collect their slots
  3. For each collected slot, print it using print-object, by inheritance order, most specific slots first
  4. If the slot is an object itself, it should be print hierarchically, with a proper indentation. That is, a tree of nested object should be print also as tree.
    E.g:
(defclass foo ()
  ((slot-a :initarg :slot-a)
   (slot-b :initarg :slot-b)))

(defclass bar (foo)
  ((slot-2nd-level :initarg :slot-2nd-level)))

(let ((a (make-instance 'bar :slot-a 12
                             :slot-b :ab
                             :slot-2nd-level (make-instance 'foo :slot-a 'a :slot-b 'b))))
  (format t "~A~%" a))
#<BAR {1004972EC3}>
Slots:
SLOT-2ND-LEVEL (BAR): #<FOO {1004972E93}>
    Slots:
    SLOT-A (FOO): A
    SLOT-B (FOO): B
SLOT-A (FOO): 12
SLOT-B (FOO): :AB

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions