Gitsis Christos
9/8/2015 9:47:00 PM
Hello, I am a new user of the cl-containers library. I wonder if it has an easy option to print nested containers readably. For example, after
(use-package :cl-containers)
(print-container
(let ((c (make-container 'associative-container)))
(setf (item-at c 1) (make-container 'basic-queue :initial-contents '(a b)))
c))
the result in the REPL is
(1 => #<BASIC-QUEUE {100876EB53}>)
and after
(defmethod print-object ((object basic-queue) stream)
(print-unreadable-object (object stream :type t)
(iterate-elements object (lambda (item) (print item stream)))))
the result in the REPL changes to
(1 => #<BASIC-QUEUE
A
B >)
which lists the elements of the queue.
How would you go about pretty printing the contents of all containers, without needing to define a print-object method for every class of container? I think the fset library does this on nested containers without any configuration at all, you don't even have to call anything like print-container.