Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!stanford.edu!ptolemy-ri!kthompso From: kthompso@ptolemy.arc.nasa.gov (Kevin Thompson) Newsgroups: comp.lang.lisp Subject: Re: shadowing defstruct print-function Message-ID: <13268@ptolemy-ri.arc.nasa.gov> Date: 31 May 91 22:11:11 GMT References: <1991May31.183953.29579@jpl-devvax.jpl.nasa.gov> Sender: usenet@ptolemy-ri.arc.nasa.gov Organization: NASA-Ames Research Center, Moffett Field, CA Lines: 37 In article eb@lucid.com (Eric Benson) writes: >In article <1991May31.183953.29579@jpl-devvax.jpl.nasa.gov> charest@ai-cyclops.jpl.nasa.gov (Len Charest) wrote: >> Is it possible to shadow the print-function used to print a >> structure during a call to FORMAT? For example, suppose we have a >> structure FOO that prints using the print-function PRINT-FOO, i.e.,: >> (format t "~a" foo) >> => # >(defstruct (foo (:print-function print-foo)) > ) > >(defvar *print-foo-hook* > #'(lambda (foo stream depth) > )) > >(defun print-foo (foo stream hook) > (funcall *print-foo-hook* foo stream hook)) > >Then your local redefinition is: > >(let ((*print-foo-hook* > #'(lambda (foo stream depth) > (declare (ignore foo depth)) > (format stream "{Foo}")))) > (format t "~a" foo)) Well this sounds great, and would be. But is there an implementation-independent way (or even implementation-dependent :) to ""? I poked around at great length in both Franz & Lucid's system packages, and didn't find in either case something like "generic-defstruct-printer", which took any struct and printed it out with the #S (?) format. Does such a beast exist? It must in some ways, but I don't know that it's accessible to the user. -- Kevin Thompson -- kthompso@ptolemy.arc.nasa.gov NASA-Ames Research Center, Moffett Field, CA