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

166 lines
11 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 CLOSED-STREAM-OPERATIONS 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/iss052_w.htm">
<LINK REL=UP HREF="../Issues/iss053.htm">
<LINK REL=NEXT HREF="../Issues/iss054_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/iss052_w.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Previous]" SRC="../Graphics/Prev.gif" ALIGN=Bottom></A><A REL=UP HREF="../Issues/iss053.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Up]" SRC="../Graphics/Up.gif" ALIGN=Bottom></A><A REL=NEXT HREF="../Issues/iss054_w.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Next]" SRC="../Graphics/Next.gif" ALIGN=Bottom></A></H1>
<HR>
<H2>Issue CLOSED-STREAM-OPERATIONS Writeup</H2>
<PRE><B>Status:</B> Passed Jan 89 X3J13 with amendment to specify that <A REL=DEFINITION HREF="../Body/f_close.htm#close"><B>CLOSE</B></A> on a<P>
closed stream returns <A REL=DEFINITION HREF="../Body/a_nil.htm#nil"><B>NIL</B></A>. At Mar 89 X3J13, amendment was withdrawn;<P>
this version stands.<P>
<P>
<B>Forum:</B> Cleanup<P>
<B>Issue:</B> <A HREF="iss053.htm">CLOSED-STREAM-OPERATIONS</A><P>
<B>References:</B> <A REL=DEFINITION HREF="../Body/f_close.htm#close"><B>CLOSE</B></A> (CLtL p 332)<P>
<B>Category:</B> CLARIFICATION<P>
<B>Edit history:</B> 26-Aug-88, Version 1 by Chapman<P>
8-Oct-88, Version 2 by Masinter<P>
13-Oct-88, Version 3 by van Roggen<P>
1-Dec-88, Version 4 by Pitman<P>
5-Dec-88, Version 5 by Masinter (separate other issues)<P>
Related Issues: <A HREF="iss327.htm">STREAM-ACCESS</A>, STREAM-INFO, INPUT-STREAM-P-CLOSED,<P>
CLOSE-CONSTRUCTED-STREAMS, <A HREF="iss261_m.htm">PATHNAME-STREAM</A><P>
<P>
<B>Problem Description:<P>
</B> <P>
The description of <A REL=DEFINITION HREF="../Body/f_close.htm#close"><B>CLOSE</B></A> is not completely clear about the functions<P>
which are allowed to be performed on a closed stream.<P>
<P>
On p332 it says:<P>
<P>
``The stream is closed. No further Input/output operations may be<P>
performed on it. However, certain inquiry operations may still<P>
be performed, ...''<P>
<P>
but the list of inquiry operations is not specified.<P>
<P>
Proposal (CLOSED-STREAM-FUNCTIONS:ALLOW-INQUIRY)<P>
<P>
Clarify the behavior of the following functions on closed streams:<P>
<P>
* <A REL=DEFINITION HREF="../Body/f_stmp.htm#streamp"><B>STREAMP</B></A> is unaffected by whether its stream argument is open or closed.<P>
<P>
* If <A REL=DEFINITION HREF="../Body/f_close.htm#close"><B>CLOSE</B></A> is called on a stream which is open, it will return T.<P>
However, if <A REL=DEFINITION HREF="../Body/f_close.htm#close"><B>CLOSE</B></A> is called on a stream which is closed, it<P>
will succeed without error but the return value is not specified.<P>
<P>
* <A REL=DEFINITION HREF="../Body/a_pn.htm#pathname"><B>PATHNAME</B></A> is valid on either an open or closed stream. Since some<P>
implementations cannot <A REL=DEFINITION HREF="../Body/f_provid.htm#provide"><B>provide</B></A> the <A REL=DEFINITION HREF="../Body/f_tn.htm#truename"><B>truename</B></A> of a file until the<P>
file is closed, it would in principle be possible for <A REL=DEFINITION HREF="../Body/a_pn.htm#pathname"><B>PATHNAME</B></A> in<P>
some implementations to return more specific information after the<P>
stream is closed. For consistency, however, <A REL=DEFINITION HREF="../Body/a_pn.htm#pathname"><B>PATHNAME</B></A> is prohibited<P>
from doing this. <A REL=DEFINITION HREF="../Body/a_pn.htm#pathname"><B>PATHNAME</B></A> must return the same <A REL=DEFINITION HREF="../Body/a_pn.htm#pathname"><B>pathname</B></A> after a<P>
file is closed as it did before. (The passed proposal in issue<P>
<A HREF="iss261_m.htm">PATHNAME-STREAM</A> still stands.)<P>
<P>
* <A REL=DEFINITION HREF="../Body/f_tn.htm#truename"><B>TRUENAME</B></A> is valid on either an open or closed stream. Since some<P>
implementations cannot <A REL=DEFINITION HREF="../Body/f_provid.htm#provide"><B>provide</B></A> the <A REL=DEFINITION HREF="../Body/f_tn.htm#truename"><B>truename</B></A> of a file until the<P>
file is closed, it is permissible <A REL=DEFINITION HREF="../Body/f_tn.htm#truename"><B>TRUENAME</B></A> to return more specific<P>
information after the stream is closed.<P>
<P>
* <A REL=DEFINITION HREF="../Body/f_merge_.htm#merge-pathnames"><B>MERGE-PATHNAMES</B></A>, <A REL=DEFINITION HREF="../Body/f_pn_hos.htm#pathname-host"><B>PATHNAME-HOST</B></A>, <A REL=DEFINITION HREF="../Body/f_pn_hos.htm#pathname-device"><B>PATHNAME-DEVICE</B></A>, <A REL=DEFINITION HREF="../Body/f_pn_hos.htm#pathname-directory"><B>PATHNAME-DIRECTORY</B></A>,<P>
<A REL=DEFINITION HREF="../Body/f_pn_hos.htm#pathname-name"><B>PATHNAME-NAME</B></A>, <A REL=DEFINITION HREF="../Body/f_pn_hos.htm#pathname-type"><B>PATHNAME-TYPE</B></A>, <A REL=DEFINITION HREF="../Body/f_pn_hos.htm#pathname-version"><B>PATHNAME-VERSION</B></A>, <A REL=DEFINITION HREF="../Body/f_namest.htm#namestring"><B>NAMESTRING</B></A>, <P>
<A REL=DEFINITION HREF="../Body/f_namest.htm#file-namestring"><B>FILE-NAMESTRING</B></A>, <A REL=DEFINITION HREF="../Body/f_namest.htm#directory-namestring"><B>DIRECTORY-NAMESTRING</B></A>, <A REL=DEFINITION HREF="../Body/f_namest.htm#host-namestring"><B>HOST-NAMESTRING</B></A>, <P>
<A REL=DEFINITION HREF="../Body/f_namest.htm#enough-namestring"><B>ENOUGH-NAMESTRING</B></A>, and <A REL=DEFINITION HREF="../Body/f_open.htm#open"><B>OPEN</B></A> are valid on either open or closed streams.<P>
For any of these operations, using a stream, S, as an argument <P>
where appropriate is equivalent to using (<A REL=DEFINITION HREF="../Body/a_pn.htm#pathname"><B>PATHNAME</B></A> s). See the<P>
description of <A REL=DEFINITION HREF="../Body/a_pn.htm#pathname"><B>PATHNAME</B></A> above to understand the consequences of this.<P>
<P>
* <A REL=DEFINITION HREF="../Body/f_probe_.htm#probe-file"><B>PROBE-FILE</B></A> and <A REL=DEFINITION HREF="../Body/f_dir.htm#directory"><B>DIRECTORY</B></A> are valid on either open or closed streams.<P>
For either of these operations, using a stream, S, as an argument <P>
where appropriate is equivalent to using (<A REL=DEFINITION HREF="../Body/a_pn.htm#pathname"><B>PATHNAME</B></A> s). See the<P>
description of <A REL=DEFINITION HREF="../Body/a_pn.htm#pathname"><B>PATHNAME</B></A> above to understand the consequences of this.<P>
In this case of these operators however, closed stream may well be the<P>
most reliable arguments in some cases, since treatment of open streams<P>
to the file system may vary considerably between implementations.<P>
For example, in some operating systems, open files are written under<P>
temporary names and not renamed until close and/or are held invisible<P>
until a close is performed. In general, any code with an intent to be<P>
highly portable should tread lightly when using <A REL=DEFINITION HREF="../Body/f_probe_.htm#probe-file"><B>PROBE-FILE</B></A> or<P>
<A REL=DEFINITION HREF="../Body/f_dir.htm#directory"><B>DIRECTORY</B></A>.<P>
<P>
<B>Rationale:<P>
</B> <P>
One can consider many characteristics of a stream to be independent of<P>
the ability to do I/O. Being able to determine a stream's direction and<P>
its name is often useful for debugging. A number of the descriptions in<P>
CLtL imply (weakly) the ability to work on closed streams. Functions<P>
such as <A REL=DEFINITION HREF="../Body/f_open.htm#open"><B>OPEN</B></A> and <A REL=DEFINITION HREF="../Body/f_dir.htm#directory"><B>DIRECTORY</B></A> don't really depend on the stream, but on<P>
the name of the stream.<P>
<P>
<B>Current Practice:<P>
</B> <P>
At least two implementations differ in which functions are allowed to be<P>
performed on a closed stream.<P>
<P>
<B>Cost to Implementors:<P>
</B> <P>
Unknown, but likely to be small in most implementations.<P>
<P>
A nontrivial amount of work may be necessary if the <A REL=DEFINITION HREF="../Body/a_pn.htm#pathname"><B>pathname</B></A> information<P>
is held externally and is normally deleted when the stream is closed. <P>
The implementation will have to copy the information at some time for later<P>
inquiries.<P>
<P>
<B>Cost to Users:<P>
</B><P>
Likely to be small; users of an implementation forced to change<P>
by this proposal might have to make some modifications to make their<P>
programs portable.<P>
<P>
<B>Benefits:<P>
</B> <P>
These clarifications will assist users in writing portable code.<P>
<P>
<B>Aesthetics:<P>
</B> <P>
Most people will probably see these clarifications as an improvement<P>
in aesthetics.<P>
<P>
<B>Discussion:<P>
</B><P>
There are some separate, but related, issues regarding what <A REL=DEFINITION HREF="../Body/f_close.htm#close"><B>CLOSE</B></A><P>
should do on composite streams or constructed streams such as<P>
created by <A REL=DEFINITION HREF="../Body/f_mk_bro.htm#make-broadcast-stream"><B>MAKE-BROADCAST-STREAM</B></A>. These issues will be addressed<P>
in a separate issue (CLOSE-CONSTRUCTED-STREAMS).<P>
<P>
There was some discussion on whether <A REL=DEFINITION HREF="../Body/f_in_stm.htm#input-stream-p"><B>INPUT-STREAM-P</B></A> and <A REL=DEFINITION HREF="../Body/f_in_stm.htm#output-stream-p"><B>OUTPUT-STREAM-P</B></A><P>
should return &quot;false&quot; on a stream that had been closed. The issue<P>
<A HREF="iss327.htm">STREAM-ACCESS</A> contains a proposal to add a function <A REL=DEFINITION HREF="../Body/f_open_s.htm#open-stream-p"><B>OPEN-STREAM-P</B></A><P>
which might be useful for the same purpose. This issue was separated<P>
out into a separate issue (INPUT-STREAM-P-CLOSED).<P>
<P>
The other functions in proposal STREAM-ACCESS:PROVIDE should<P>
work on closed streams.<P>
<P>
The functions in STREAM-INFO:ONE-DIMENSIONAL-FUNCTIONS should<P>
not be requred to work on closed streams.<P>
<P>
<P>
<P>
<P>
----- End Forwarded Messages -----<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>