1
0
Fork 0
cl-sites/HyperSpec-7-0/HyperSpec/Issues/iss052_w.htm
2024-04-01 10:24:07 +02:00

165 lines
10 KiB
HTML

<!-- Common Lisp HyperSpec (TM), version 7.0 generated by Kent M. Pitman on Mon, 11-Apr-2005 2:31am EDT -->
<HTML>
<HEAD>
<TITLE>CLHS: Issue CLOSE-CONSTRUCTED-STREAM Writeup</TITLE>
<LINK HREF="../Data/clhs.css" REL="stylesheet" TYPE="text/css" />
<META HTTP-EQUIV="Author" CONTENT="Kent M. Pitman">
<META HTTP-EQUIV="Organization" CONTENT="LispWorks Ltd.">
<LINK REL=TOP HREF="../Front/index.htm">
<LINK REL=COPYRIGHT HREF="../Front/Help.htm#Legal">
<LINK REL=DISCLAIMER HREF="../Front/Help.htm#Disclaimer">
<LINK REL=PREV HREF="../Issues/iss051_w.htm">
<LINK REL=UP HREF="../Issues/iss052.htm">
<LINK REL=NEXT HREF="../Issues/iss053_w.htm">
</HEAD>
<BODY>
<H1><A REV=MADE HREF="http://www.lispworks.com/"><IMG WIDTH=80 HEIGHT=65 ALT="[LISPWORKS]" SRC="../Graphics/LWSmall.gif" ALIGN=Bottom></A><A REL=TOP HREF="../Front/index.htm"><IMG WIDTH=237 HEIGHT=65 ALT="[Common Lisp HyperSpec (TM)]" SRC="../Graphics/CLHS_Sm.gif" ALIGN=Bottom></A> <A REL=PREV HREF="../Issues/iss051_w.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Previous]" SRC="../Graphics/Prev.gif" ALIGN=Bottom></A><A REL=UP HREF="../Issues/iss052.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Up]" SRC="../Graphics/Up.gif" ALIGN=Bottom></A><A REL=NEXT HREF="../Issues/iss053_w.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Next]" SRC="../Graphics/Next.gif" ALIGN=Bottom></A></H1>
<HR>
<H2>Issue CLOSE-CONSTRUCTED-STREAM Writeup</H2>
<PRE><B>Status:</B> DRAFT<P>
<B>Forum:</B> Cleanup<P>
<B>Issue:</B> <A HREF="iss052.htm">CLOSE-CONSTRUCTED-STREAM</A><P>
<P>
<B>References:</B> Close (CLtL p. 332), <A REL=DEFINITION HREF="../Body/m_w_op_1.htm#with-open-stream"><B>WITH-OPEN-STREAM</B></A> <P>
(CLtL p 330), <A REL=DEFINITION HREF="../Body/f_mk_syn.htm#make-synonym-stream"><B>make-synonym-stream</B></A>, <A REL=DEFINITION HREF="../Body/f_mk_bro.htm#make-broadcast-stream"><B>make-broadcast-stream</B></A>,<P>
<A REL=DEFINITION HREF="../Body/f_mk_con.htm#make-concatenated-stream"><B>make-concatenated-stream</B></A>, <A REL=DEFINITION HREF="../Body/f_mk_two.htm#make-two-way-stream"><B>make-two-way-stream</B></A>,<P>
<A REL=DEFINITION HREF="../Body/f_mk_ech.htm#make-echo-stream"><B>make-echo-stream</B></A>, <A REL=DEFINITION HREF="../Body/f_mk_s_1.htm#make-string-input-stream"><B>make-string-input-stream</B></A>,<P>
<A REL=DEFINITION HREF="../Body/f_mk_s_2.htm#make-string-output-stream"><B>make-string-output-stream</B></A>, <A REL=DEFINITION HREF="../Body/m_w_in_f.htm#with-input-from-string"><B>with-input-from-string</B></A>,<P>
with-output-from-string<P>
<P>
Related issues: <A HREF="iss053.htm">CLOSED-STREAM-OPERATIONS</A><P>
<P>
<B>Category:</B> Clarification/Change<P>
<P>
<B>Edit history:</B> Masinter, 6-Jan-89, Version 1<P>
Masinter, 12-Jan-89, Version 2<P>
<P>
<B>Problem description:<P>
</B><P>
First some terminology:<P>
<P>
A &quot;composite&quot; stream is one created with <A REL=DEFINITION HREF="../Body/f_mk_syn.htm#make-synonym-stream"><B>MAKE-SYNONYM-STREAM</B></A>, <P>
<A REL=DEFINITION HREF="../Body/f_mk_bro.htm#make-broadcast-stream"><B>MAKE-BROADCAST-STREAM</B></A>, <A REL=DEFINITION HREF="../Body/f_mk_con.htm#make-concatenated-stream"><B>MAKE-CONCATENATED-STREAM</B></A>, <A REL=DEFINITION HREF="../Body/f_mk_two.htm#make-two-way-stream"><B>MAKE-TWO-WAY-STREAM</B></A>, <P>
<A REL=DEFINITION HREF="../Body/f_mk_ech.htm#make-echo-stream"><B>MAKE-ECHO-STREAM</B></A>. <P>
<P>
The &quot;constituents&quot; of a composite stream are the streams it points to:<P>
the <A REL=DEFINITION HREF="../Body/f_symb_5.htm#symbol-value"><B>SYMBOL-VALUE</B></A> of the symbol given to <A REL=DEFINITION HREF="../Body/f_mk_syn.htm#make-synonym-stream"><B>MAKE-SYNONYM-STREAM</B></A><P>
the streams given to <A REL=DEFINITION HREF="../Body/f_mk_bro.htm#make-broadcast-stream"><B>MAKE-BROADCAST-STREAM</B></A> or <A REL=DEFINITION HREF="../Body/f_mk_con.htm#make-concatenated-stream"><B>MAKE-CONCATENATED-STREAM</B></A><P>
the input-stream and output-stream given to <A REL=DEFINITION HREF="../Body/f_mk_two.htm#make-two-way-stream"><B>MAKE-TWO-WAY-STREAM</B></A> or <A REL=DEFINITION HREF="../Body/f_mk_ech.htm#make-echo-stream"><B>MAKE-ECHO-STREAM</B></A>.<P>
<P>
A &quot;constructed&quot; stream is either a composite stream or one created with <P>
<A REL=DEFINITION HREF="../Body/f_mk_s_1.htm#make-string-input-stream"><B>MAKE-STRING-INPUT-STREAM</B></A>, <A REL=DEFINITION HREF="../Body/f_mk_s_2.htm#make-string-output-stream"><B>MAKE-STRING-OUTPUT-STREAM</B></A>, <A REL=DEFINITION HREF="../Body/m_w_in_f.htm#with-input-from-string"><B>WITH-INPUT-FROM-STRING</B></A>,<P>
WITH-OUTPUT-FROM-STRING.<P>
<P>
The function &quot;CLOSE&quot; is currently described in 21.3, which starts &quot;This<P>
section contains discussion of only those operations that are common to all<P>
streams.&quot; This would seem to imply that they apply to constructed streams. <P>
<P>
The definition of <A REL=DEFINITION HREF="../Body/f_close.htm#close"><B>CLOSE</B></A> &quot;The argument must be a stream. No further input/output<P>
operations may be performed on it. ... &quot; It further states &quot;... and it is <P>
permissible to close an already closed stream.&quot;<P>
<P>
However, the behavior on the constructed streams is not well defined, and<P>
implementations (apparently) differ.<P>
<P>
<B>Proposal (CLOSE-CONSTRUCTED-STREAM:IS-ERROR): <P>
</B><P>
It &quot;is an error&quot; to call <A REL=DEFINITION HREF="../Body/f_close.htm#close"><B>CLOSE</B></A> on a constructed stream. <A REL=DEFINITION HREF="../Body/f_close.htm#close"><B>CLOSE</B></A> might signal an<P>
error, or the result of <A REL=DEFINITION HREF="../Body/f_close.htm#close"><B>CLOSE</B></A> could cause the constituent streams to be closed,<P>
etc, but the effect is implementation-dependent.<P>
<P>
Proposal: (CLOSE-CONSTRUCTED-STREAM:SIGNALS-ERROR)<P>
<P>
Calling <A REL=DEFINITION HREF="../Body/f_close.htm#close"><B>CLOSE</B></A> on a constructed stream signals an error.<P>
<P>
<B>Proposal (CLOSE-CONSTRUCTED-STREAM:ARGUMENT-STREAM-ONLY):<P>
</B><P>
The effect of <A REL=DEFINITION HREF="../Body/f_close.htm#close"><B>CLOSE</B></A> on a constructed stream is to close the &quot;argument&quot; stream<P>
only. No i/o operations are permitted after the call to <A REL=DEFINITION HREF="../Body/f_close.htm#close"><B>CLOSE</B></A> on the stream<P>
given to CLOSE; There is no effect on the constituents of composite streams.<P>
<P>
For streams created with <A REL=DEFINITION HREF="../Body/f_mk_s_2.htm#make-string-output-stream"><B>MAKE-STRING-OUTPUT-STREAM</B></A>, the result of<P>
<A REL=DEFINITION HREF="../Body/f_get_ou.htm#get-output-stream-string"><B>GET-OUTPUT-STREAM-STRING</B></A> is unspecified after CLOS. For composite streams,<P>
the call to <A REL=DEFINITION HREF="../Body/f_close.htm#close"><B>CLOSE</B></A> has no effect on any of the constituent streams.<P>
<P>
The &quot;links&quot; to the constituents may be broken; if the proposal in <A HREF="iss327.htm">STREAM-ACCESS</A> <P>
passes, the results of the accessor functions there are unspecified after the<P>
call to <A REL=DEFINITION HREF="../Body/f_close.htm#close"><B>CLOSE</B></A>.)<P>
<P>
Proposal: (CLOSE-CONSTRUCTED-STREAM:CLOSE-CONSTITUENTS)<P>
<P>
<A REL=DEFINITION HREF="../Body/f_close.htm#close"><B>CLOSE</B></A> first closes its argument; it then operates recursively on the constituents<P>
of composite streams.<P>
<P>
<B>Examples:<P>
</B><P>
&gt;&gt;not written; sorry&lt;&lt;<P>
<P>
<B>Rationale:<P>
</B><P>
Specifying seems better than not saying what happens, even if it is<P>
&quot;implementation-dependent&quot;.<P>
<P>
<B>Current practice:<P>
</B><P>
Implementations seem to vary widely.<P>
<P>
<B>Cost to Implementors:<P>
</B><P>
Varying, depending on the current level of conformance. Making the changes<P>
themselves is probably trivial (to the &quot;close&quot; <A REL=DEFINITION HREF="../Body/t_method.htm#method"><B>method</B></A> for each kind of<P>
constructed stream type) but it is possible that system code might depend<P>
on the behavior.<P>
<P>
<B>Cost to Users:<P>
</B><P>
Likely small; we've not found any good uses for <A REL=DEFINITION HREF="../Body/f_close.htm#close"><B>CLOSE</B></A> on composite streams.<P>
<P>
<B>Cost of non-adoption:<P>
</B><P>
Continued minor ambiguity<P>
<P>
<B>Performance impact:<P>
</B><P>
near zero<P>
<P>
<B>Benefits:<P>
</B><P>
The language would be more well specified.<P>
<P>
<B>Esthetics:<P>
</B><P>
Well-specified languages are usually easier to deal with.<P>
<P>
<B>Discussion:<P>
</B><P>
Signalling an error is reasonable if no Common Lisp program ever needs to<P>
call <A REL=DEFINITION HREF="../Body/f_close.htm#close"><B>CLOSE</B></A> on a composite stream. We could not come up with a legitimate<P>
case where you wouldn't instead close the underlying stream if that's what<P>
you wanted.<P>
<P>
Allowing the result to be implementation dependent is the &quot;status quo&quot;. <P>
<P>
ARGUMENT-STREAM-ONLY is probably the &quot;safest&quot; in that it makes it<P>
harder to accidentally close a stream that wasn't intended. It<P>
seems counterintuitive and yet it probably wouldn't be harmful<P>
if it were well-defined that this was what it did.<P>
<P>
CLOSE-CONSTITUENTS could be an incompatible change for some<P>
implementations. It makes more sense for things like broadcast streams<P>
(which are usually non-interactive) than it does for echo streams<P>
(which are sometimes interactive).<P>
<P>
</PRE>
<HR>
<A REL=NAVIGATOR HREF="../Front/StartPts.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Starting Points]" SRC="../Graphics/StartPts.gif" ALIGN=Bottom></A><A REL=TOC HREF="../Front/Contents.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Contents]" SRC="../Graphics/Contents.gif" ALIGN=Bottom></A><A REL=INDEX HREF="../Front/X_Master.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Index]" SRC="../Graphics/Index.gif" ALIGN=Bottom></A><A REL=INDEX HREF="../Front/X_Symbol.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Symbols]" SRC="../Graphics/Symbols.gif" ALIGN=Bottom></A><A REL=GLOSSARY HREF="../Body/26_a.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Glossary]" SRC="../Graphics/Glossary.gif" ALIGN=Bottom></A><A HREF="../Front/X3J13Iss.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Issues]" SRC="../Graphics/Issues.gif" ALIGN=Bottom></A><BR>
<A REL=COPYRIGHT HREF="../Front/Help.htm#Legal"><I>Copyright 1996-2005, LispWorks Ltd. All rights reserved.</I></A><P>
</BODY>
</HTML>