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

Re: no describe?



>From Ken Tilton:
> Is there some other method I override to achieve the same
> end:controlling the appearance of raw object descriptions?

Err, I'm not familiar with Keene's "describe" but if what you want to
create is a default printed representation for your classes, write a
method on the generic function print-object.  Here's a silly example:

? (defclass foo () ())
#<STANDARD-CLASS FOO>
? (defmethod print-object ((obj foo) stream)
      (format stream "GOT A FOO!"))    ; you can of course put args here
#<STANDARD-METHOD PRINT-OBJECT (FOO T)>
? (setf afoo (make-instance 'foo))
GOT A FOO!
?

The print system will, for example, use this method when you print an
object with the ~S format directive, or when you use the print
function.  See CLtl2 pgs 850-852 for details.

Hope this is somehow related to what you wanted...

Ethan

Ethan Benatan
ethan+@pitt.edu