close of an arbitrary stream may close *terminal-io* 
Author Message
 close of an arbitrary stream may close *terminal-io*

Redirecting output to a file seems simple:

(with-open-stream (out (open "file" :direction output))
     ... )

But sometimes I would prefer output on the console:

(with-open-stream (out (if writeToFileIfTrue (open "file" :direction output)
                                *standard-output*))
     ... )

Problem:

When with-open-stream terminates, the system tries to
close *standard-output*.

First idea:

clone *standard-output* with make-synonym-stream.

Problem:

the closing of the synonym stream closes *standard-output* as well.
This is according to documentation (at least the old common lisp one)
and can be verified in the implementations of akcl and cmu lisp.

Ok, you can always use unwind-protect instead of with-open-stream.
But the above is only a simple example. My complaint is, that
it seems to be impossible to get a handle to a stream, which
can be manipulated (that is closed) without affecting the
original stream. In particular, *standard-input*, *standard-output*,
*error-output*,*trace-output*,*query-io* are all synonyms of
*terminal-io*. Closing any of those streams will result in
closing *termial-io*.

Writing a new close function, which avoids closing synonym
streams is impossibe in an implementation independent way,
since there is no predicate to test for a synonym stream.

Juergen Weiss

--
Juergen Weiss         Gesellschaft fuer Mathematik und Datenverarbeitung (GMD)
                      Institut I1, Postfach 1316
                      53731 Sankt Augustin, Germany



Sun, 29 Sep 1996 00:08:16 GMT  
 close of an arbitrary stream may close *terminal-io*

   Redirecting output to a file seems simple:

   (with-open-stream (out (open "file" :direction output))
        ... )

   But sometimes I would prefer output on the console:

   (with-open-stream (out (if writeToFileIfTrue (open "file" :direction output)
                                   *standard-output*))
        ... )

   Problem:

   When with-open-stream terminates, the system tries to
   close *standard-output*.

Perhaps it would work to use:

  (with-open-stream (out (make-broadcast-stream *standard-output*))
     ... )

Wayne Hyatt
AT&T (Bell Laboratories)



Sun, 29 Sep 1996 07:42:10 GMT  
 close of an arbitrary stream may close *terminal-io*

   First idea:

   clone *standard-output* with make-synonym-stream.

   Problem:

   the closing of the synonym stream closes *standard-output* as well.
   This is according to documentation (at least the old common lisp one)
   and can be verified in the implementations of akcl and cmu lisp.

CLtL2, p. 506, specifies: "Closing a composite stream has no effect on
its constituents; any constituents that are open remain open."  On the
same page: "A composite stream is one that was returned by a call to
MAKE-SYNONYM-STREAM, MAKE-BROADCAST-STREAM, MAKE-CONCATENATED-STREAM,
MAKE-TWO-WAY-STREAM, or MAKE-ECHO-STREAM."

   Writing a new close function, which avoids closing synonym
   streams is impossibe in an implementation independent way,
   since there is no predicate to test for a synonym stream.

P. 500 of CLtL2 specifies that "the result of MAKE-SYNONYM-STREAM is
always a stream of type SYNONYM-STREAM."  Hence a suitable test is

(typep <stream> 'synonym-stream)

--
        Lawrence G. Mayka
        AT&T Bell Laboratories

Standard disclaimer.



Mon, 30 Sep 1996 22:07:41 GMT  
 close of an arbitrary stream may close *terminal-io*

WARNING: flame bait included!
:-)

   Newsgroups: comp.lang.lisp

   Keywords: with-open-stream, make-synonym-stream

   Nntp-Posting-Host: casun
   Organization: GMD, Sankt Augustin, Germany
   Date: Tue, 12 Apr 1994 16:08:16 GMT
   Lines: 52

   Redirecting output to a file seems simple:

   (with-open-stream (out (open "file" :direction output))
        ... )

   But sometimes I would prefer output on the console:

   (with-open-stream (out (if writeToFileIfTrue (open "file" :direction output)
                                   *standard-output*))
        ... )

Please, avoid ugly "C++" style in this group. Use:

(with-open-stream (out (if *write-to-file-p*
                           (open "file" :direction output)
                           *standard-output*))
  ... )

:-) :-)
--
Marco Antoniotti - Resistente Umano
-------------------------------------------------------------------------------
Robotics Lab            | room: 1220 - tel. #: (212) 998 3370

...e` la semplicita` che e` difficile a farsi.
...it is simplicity that is difficult to make.
                                Bertholdt Brecht



Tue, 01 Oct 1996 00:36:30 GMT  
 close of an arbitrary stream may close *terminal-io*

Quote:

>the closing of the synonym stream closes *standard-output* as well.
>This is according to documentation (at least the old common lisp one)
>and can be verified in the implementations of akcl and cmu lisp.

I'm surprised CMU CL still has this bug.  CLtL2 clarifies that closing a
composite stream should not affect the streams it references.
--
Barry Margolin
System Manager, Thinking Machines Corp.




Thu, 03 Oct 1996 13:30:24 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. CW55PE release H when I close a wizard generated application the IDE closes as well

2. mdi app not closing down, some threads just won't close #2

3. Device file not closing on close command

4. to close or not to close?

5. tcl-dp confuses expect's close call with builtin close

6. Dangling Closing Parentheses vs. Stacked Closing Parentheses

7. Closed file not really closed

8. Cant close window under w2k terminal server - Help

9. How do I deiconify after terminal closes.

10. Vacation Notice: We will be closed May 24 through June 02, 2003

11. Overriding IO#close

12. Streams being closed in NT?

 

 
Powered by phpBB® Forum Software