[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Printing objects created by make-instance
- To: info-macl@cambridge.apple.com, tusneem@ecn.purdue.edu
- Subject: Re: Printing objects created by make-instance
- From: Ranson <ranson@lannion.cnet.fr>
- Date: 24 Jul 91 08:12:00 GMT
- Cc: ranson@lannion.cnet.fr
- X400-received: by /PRMD=inria/ADMD=atlas/C=FR/; Relayed; 24 Jul 91 08:11:53+0200
- X400-received: by /PRMD=CNET/ADMD=ATLAS/C=FR/; Relayed; 24 Jul 91 08:12:00 GMT
The command is called PRINT :-)
The default printing method for your classes of objects gives text not suitable
for READ. To customize the printing of your objects, define a method for
PRINT-OBJECT.
(defclass foo () ((x :initarg :x :accessor foo-x)))
(defmethod print-object ((u foo) stream)
(format stream "#.(make-instance 'foo :x '~S)" (foo-x u)))
I haven't tested this code, and it is probably unsuitable for your needs, but
it could give you ideas.
Daniel Ranson (ranson@lannion.cnet.fr)