[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

a problem with print-functions



    Date: Fri, 27 May 88 11:25:33 EDT
    From:     bds@mitre-bedford.ARPA

    It is possible to partially solve the problem in the inspector by
    making all the defstructs unnamed vectors, which print out in a
    similar manner to flavors.  However, this is unnacceptable since
    the slot names don't show in the inspector and since I also need
    to do quite a bit of typing in the code and if the structure is
    unnamed you lose the ability to test for type (eg, if rts is an
    unnamed structure, (rts-p var) won't work.

(SETF SCL:*PRINT-STRUCTURE-CONTENTS* NIL)

Or, you can define printers for the structures.  This example is
"pure" Common Lisp.

(defstruct (foo (:print-function print-random-object))
  ...)

(defun print-random-object (object stream depth)
  (declare (ignore depth))
  (format stream "#<~S structure ~S>"
        (type-of object)
        #+3600 (sys:%pointer object)
        #-3600 'address-unavailable))

Of course, you can have a separate, more meaningful print-function
for each of your different structure types.

-- Stephen