[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

    Now for the problem: I use forward and backpointers a lot.  During
    development I spent as much time in the inspector as I did in the
    editor.  With flavors this was no problem, since flavors print
    as "unprintable "structures.  Pointers from one flavor to another
    were no problem, and all I had to do is mouse on the slot to
    expand it.  Defstructs are another matter--they want to print
    out every slot.  This can be partially solved by using print-functions, 
    of course, but  since most of the structures have between 6 and 12
    slots (some of which are lists of other structures),
    the printouts become long and unwieldy, and the individual
    slots are not mouseable in the  inspector.  

I don't understand this last point.  The Inspector doesn't use the print
function when inspecting a structure, although it uses it when showing the
slot values.  Here's what I tried:

Command: (defstruct (frob1 (:print-function print-frob1))
	   a b c)
FROB1
Command: (defun print-frob1 (frob1 stream ignore)
	   (format stream "#<FROB1 :A ~S :C ~S>" (frob1-a frob1) (frob1-c frob1)))
PRINT-FROB1
Command: (make-frob1)
#<FROB1 :A NIL :C NIL>
Command: (defstruct (frob2 (:print-function print-frob2))
	   a b c)
FROB2
Command: (defun print-frob2 (frob2 stream ignore) 
	   (format stream "#<FROB2 :A ~S :B ~S>" (frob2-a frob2) (frob2-b frob2)))
PRINT-FROB2
Command: (make-frob2)
#<FROB2 :A NIL :B NIL>
Command: (setq frob1 (make-frob1 :a 3 :c 'ten))
#<FROB1 :A 3 :C TEN>
Command: (setq frob2 (make-frob2 :a 'frob2-a :c frob1))
#<FROB2 :A FROB2-A :B NIL>
Command: (setf (frob1-b frob1) frob2)
#<FROB2 :A FROB2-A :B NIL>

I then went into the Inspector and looked at FROB1, which it displayed
as
1#<FROB1 :A 3 :C TEN>
0Named structure of type FROB1

A:  3
B:  #<FROB2 :A FROB2-A :B NIL>
C:  TEN

I could click on any of the values without any problems.

                                                barmar