From: Sunil Mishra
Subject: Re: printing structures
Date: 
Message-ID: <efywwhy42c8.fsf@cleon.cc.gatech.edu>
In article <·············@wintermute.eagle> Sam Shteingold <···········@cctrading.com> writes:

   From: Sam Shteingold <···········@cctrading.com>
   Newsgroups: comp.lang.lisp
   Date: 24 Nov 1997 11:41:34 -0500
   Organization: disorganization
   Path: cc.gatech.edu!cssun.mathcs.emory.edu!uunet!in4.uu.net!news.eden.com!mr.net!news.maxwell.syr.edu!cpk-news-hub1.bbnplanet.com!news.bbnplanet.com!newsfeed.internetmci.com!199.0.154.56!ais.net!newsfeed.concentric.net!global-news-master
   Lines: 20
   Sender: ···@WINTERMUTE
   Return-Receipt-To: ···········@cctrading.com
   X-Disclaimer: You should not expect anyone to agree with me.
   X-No-Archive: Yes
   Mail-Copies-To: ···········@cctrading.com
   X-Newsreader: Gnus v5.3/Emacs 19.34

   Suppose I have a structure 
   (defstruct (zz (:print-function print-zz)) (aa) (bb))
   I want to define print-zz so that it will print something pretty if
   *print-pretty* is non-nil and the #S thing otherwise. I can, of course,
   use
   (defun print-zz (zz stream depth)
     (if *print-pretty* ;; or *print-readably* ?
	 (format stream "ZZ: ~a (aa); ~a (bb)" (zz-aa zz) (zz-bb zz))
	 (format stream "#S(zz :aa ~s :bb ~s)" (zz-aa zz) (zz-bb zz))))

   It would be nice though if I could replace the last line with something
   like (print-struct-in-standard-notation zz). Apparently, writing such a
   function boils down to using MOP to get the list of all slots (right?)
   Did I overlook something? Is there a way to achieve this simpler?
   Like, maybe there is a way to print a structure in the #S notation even
   when :print-function was specified?

   Thanks.
   -- 
   Sam Steingold

Have a look at the macro print-ureadable-object

Sunil