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

How do you override CLOS:PRINT-OBJECT?

    Date: Fri, 15 Jun 1990 18:37:17 EDT
    From: DUMOULIN@TITAN.KSC.NASA.GOV (Jim Dumoulin)

    I have an application that was written under Release 7.2 using Xerox's
    Public domain CLOS (PCL - May Day version).  It's a Telemetry processing
    system that uses thousands of CLOS objects of Class MEASUREMENT in our
    package SPORT - (Smart Processing of Real Time Telemetry).  The system 
    attempts to process and display them graphically.  To aid in debugging, 
    we wanted to change the default PRINT-OBJECT method to print additional
    name information utilizing a NAME slot in the object.  In PCL we were 
    defining the method as follows: 


The second version is almost what you want.  You just need to discard
the superfluous &REST IGNORE in the lambda list.  That is, rather than

    ;;; Gets you Error - Lambda lists aren't congruent
    (CLOS:defmethod CLOS:print-object ((m SPORT::measurement) stream &rest ignore)
      (format stream "#<~A-~A>"
	      (CLOS:class-name (CLOS:class-of m))
	      (sport::m-name m)))

You want this:

    ;;; No error.
    (CLOS:defmethod CLOS:print-object ((m SPORT::measurement) stream)
      (format stream "#<~A-~A>"
	      (CLOS:class-name (CLOS:class-of m))
	      (sport::m-name m)))