From: Dharmendra Sharma
Subject: Problem with defstruct printing in Common Lisp
Date: 
Message-ID: <dsharma.669010518@kaffa>
I would like to be able to print a defstruct object on more than 1
stream i.e. on the screen and to a file. How can I do it with a
predefined :print-function?
Thanx.

--
* Dharmendra ····················@anucsd.anu.edu.AU-post:                    *
*Computer Science Department, ANU, GPO Box 4, Canberra ACT 2601, Australia   *
*From down under                      | Live to study and not study to live  *
******************************************************************************

From: Raymond K. Fink
Subject: Re: Problem with defstruct printing in Common Lisp
Date: 
Message-ID: <1991Mar15.165013.22368@inel.gov>
In article <·················@kaffa>, ·······@kaffa.anu.oz.au (Dharmendra Sharma) writes:
>I would like to be able to print a defstruct object on more than 1
>stream i.e. on the screen and to a file. How can I do it with a
>predefined :print-function?
>Thanx.

0- Presuming that the :print-function takes a stream argument......
1- First create a stream to the file
2- use (make-broadcast-stream <file-stream> *standard-output*) to create a stream that
   will  broadcast stuff to multiple streams.

Ray Fink -- Idaho National Engineering Laboratory -- Idaho Falls ID 
	···@inel.gov			208-526-9323
========== long legal disclaimer follows, press n to skip ===========

Neither the United States Government or the Idaho National Engineering
Laboratory or any of their employees, makes any warranty, whatsoever,
implied, or assumes any legal liability or responsibility regarding any
information, disclosed, or represents that its use would not infringe
privately owned rights.  No specific reference constitutes or implies
endorsement, recommendation, or favoring by the United States
Government or the Idaho National Engineering Laboratory.  The views and
opinions expressed herein do not necessarily reflect those of the
United States Government or the Idaho National Engineering Laboratory,
and shall not be used for advertising or product endorsement purposes.
From: Barry Margolin
Subject: Re: Problem with defstruct printing in Common Lisp
Date: 
Message-ID: <1991Mar15.183935.16362@Think.COM>
In article <·················@kaffa> ·······@kaffa.anu.oz.au (Dharmendra Sharma) writes:
>I would like to be able to print a defstruct object on more than 1
>stream i.e. on the screen and to a file. How can I do it with a
>predefined :print-function?

I have a feeling you're not describing your problem correctly, or you're
very confused.

To print something on more than one stream, you can call PRINT multiple
times, e.g.:

	(progn
	  (print my-object *standard-output*)
	  (print my-object file-stream))

If you want to print lots of stuff to both streams without having to double
all your PRINT forms, you can use a broadcast stream:

	(with-open-stream (bs (make-broadcast-stream *standard-output* file-stream))
	  (print my-object bs)
	  ...)

The fact that a defstruct type has a :PRINT-FUNCTION is immaterial.  The
:PRINT-FUNCTION specifies what the output looks like, but not where it
goes; the stream is a parameter to this function, and that's the only
stream it should perform any output to.  It's probably also a bad idea for
a :PRINT-FUNCTION to have *any* side effects other than output to the given
stream; however, CLtL doesn't specifically mention such a restriction (at
least not in the descriptions of :PRINT-FUNCTION and PRINT-OBJECT).


--
Barry Margolin, Thinking Machines Corp.

······@think.com
{uunet,harvard}!think!barmar