In article <LIBERTE.92Sep9132646@birch.cs.uiuc.edu>, liberte@cs.uiuc.edu (Daniel LaLiberte) writes:
|> In article <1992Sep9.011022.14516@jpl-devvax.jpl.nasa.gov> charest@Aig.Jpl.Nasa.Gov (Len Charest) writes:
|>
|> 3. (mutually exclusive) Use CLOS. Ha Ha only serious.
|>
|>
|> I took this suggestion seriously. It wasnt obvious (to me) at first
|> how one is supposed to print an object readably. I wrote the
|> following to help. Please comment.
[ sample code deleted]
MAKE-LOAD-FORM (CLtL2, p659) could be exploited to provide readable printed representations for structures and CLOS instances. I believe you would still need an :around method on PRINT-OBJECT to test *PRINT-READABLY* and explicitly invoke MAKE-LOAD-FORM. The real benefit of MAKE-LOAD-FORM is that it allows the programmer to decide the meaning of 'similar as a constant' for structures and CLOS instances. (Recall that objects printed while *PRINT-READABLY* is true must be similar as a constant.) CLtL2 gives
several examples. In the first, the notion of similar as a constant is satisfied by instantiating a new instance with the same slot values as the original instance. This is the same approach used in Dan LaLiberte's code.
As a parting shot, I'd like to point out that readable printed representations for structures (or any other object for that matter) don't necessarily have to use #S syntax. You could define a new # dispatch macro reader that simply read back in as a form to 'find' the printed object in some global cache. For example: