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

193 lines
13 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 STREAM-ACCESS 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/iss326_w.htm">
<LINK REL=UP HREF="../Issues/iss327.htm">
<LINK REL=NEXT HREF="../Issues/iss328_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/iss326_w.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Previous]" SRC="../Graphics/Prev.gif" ALIGN=Bottom></A><A REL=UP HREF="../Issues/iss327.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Up]" SRC="../Graphics/Up.gif" ALIGN=Bottom></A><A REL=NEXT HREF="../Issues/iss328_w.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Next]" SRC="../Graphics/Next.gif" ALIGN=Bottom></A></H1>
<HR>
<H2>Issue STREAM-ACCESS Writeup</H2>
<PRE>Proposal ADD-TYPES-ACCESSORS was accepted at the January 1989 meeting.<P>
<P>
-----<P>
<B>Issue:</B> <A HREF="iss327.htm">STREAM-ACCESS</A><P>
<B>References:</B> streams (Chapter 21 of CLtL)<P>
<B>Category:</B> ADDITION<P>
<B>Edit History:</B> 17-Jun-88, version 1 by Walter van Roggen<P>
30-Nov-88, version 2 by Masinter<P>
<P>
<B>Problem Description:<P>
</B><P>
There are many components of streams which are specified upon creation<P>
but are not accessible afterwards. Furthermore there is no way in<P>
Common Lisp to determine the type of a stream to see if it has particular<P>
components, or even if it is <A REL=DEFINITION HREF="../Body/f_open.htm#open"><B>OPEN</B></A>.<P>
<P>
The accessors wanted are those associated with broadcast streams,<P>
concatenated streams, echo streams, file streams, string streams, <P>
synonym streams, two way streams.<P>
<P>
There are three proposals, which differ only by the whether<P>
they include types, type predicates, or both, in addition to<P>
the stream component acessors. Ballots can be either for<P>
one of the proposals or none. (Other combinations of, say, <P>
accessors without either predicates or types, or types without<P>
accessors, do not seem reasonable and are not being proposed<P>
at this time.)<P>
<P>
<P>
Proposal STREAM-ACCESS:ADD-TYPES-PREDICATES-ACCESSORS<P>
<P>
<P>
First, add a function to determine whether a stream is &quot;OPEN&quot;:<P>
<P>
<A REL=DEFINITION HREF="../Body/f_open_s.htm#open-stream-p"><B>OPEN-STREAM-P</B></A> stream [Function]<P>
<P>
Returns T if a stream is open, <A REL=DEFINITION HREF="../Body/a_nil.htm#nil"><B>NIL</B></A> if it is closed. It is an error<P>
if the argument is not a stream.<P>
<P>
Streams are &quot;open&quot; until they have been closed with<P>
<A REL=DEFINITION HREF="../Body/f_close.htm#close"><B>CLOSE</B></A>, or, the dynamic context of the creating/accessing<P>
macros of <A REL=DEFINITION HREF="../Body/m_w_out_.htm#with-output-to-string"><B>WITH-OUTPUT-TO-STRING</B></A>, <A REL=DEFINITION HREF="../Body/m_w_open.htm#with-open-file"><B>WITH-OPEN-FILE</B></A>, <P>
<A REL=DEFINITION HREF="../Body/m_w_in_f.htm#with-input-from-string"><B>WITH-INPUT-FROM-STRING</B></A>, <A REL=DEFINITION HREF="../Body/m_w_op_1.htm#with-open-stream"><B>WITH-OPEN-STREAM</B></A>, <P>
have been exited.<P>
<P>
There are three kinds of things to add associated with each kind of<P>
stream: data types, predicates, accessors.<P>
<P>
Stream data types:<P>
<A REL=DEFINITION HREF="../Body/t_broadc.htm#broadcast-stream"><B>BROADCAST-STREAM</B></A> (returned by <A REL=DEFINITION HREF="../Body/f_mk_bro.htm#make-broadcast-stream"><B>MAKE-BROADCAST-STREAM</B></A>)<P>
<A REL=DEFINITION HREF="../Body/t_concat.htm#concatenated-stream"><B>CONCATENATED-STREAM</B></A> (returned by <A REL=DEFINITION HREF="../Body/f_mk_con.htm#make-concatenated-stream"><B>MAKE-CONCATENATED-STREAM</B></A>)<P>
<A REL=DEFINITION HREF="../Body/t_echo_s.htm#echo-stream"><B>ECHO-STREAM</B></A> (returned by <A REL=DEFINITION HREF="../Body/f_mk_ech.htm#make-echo-stream"><B>MAKE-ECHO-STREAM</B></A>)<P>
<A REL=DEFINITION HREF="../Body/t_file_s.htm#file-stream"><B>FILE-STREAM</B></A> (returned by <A REL=DEFINITION HREF="../Body/f_open.htm#open"><B>OPEN</B></A> or created by <A REL=DEFINITION HREF="../Body/m_w_open.htm#with-open-file"><B>WITH-OPEN-FILE</B></A>)<P>
<A REL=DEFINITION HREF="../Body/t_stg_st.htm#string-stream"><B>STRING-STREAM</B></A> (returned by <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>, and created by <A REL=DEFINITION HREF="../Body/m_w_in_f.htm#with-input-from-string"><B>WITH-INPUT-FROM-STRING</B></A><P>
and <A REL=DEFINITION HREF="../Body/m_w_out_.htm#with-output-to-string"><B>WITH-OUTPUT-TO-STRING</B></A> and <A REL=DEFINITION HREF="../Body/f_format.htm#format"><B>FORMAT</B></A> with second argument <A REL=DEFINITION HREF="../Body/a_nil.htm#nil"><B>NIL</B></A>)<P>
<A REL=DEFINITION HREF="../Body/t_syn_st.htm#synonym-stream"><B>SYNONYM-STREAM</B></A> (created by <A REL=DEFINITION HREF="../Body/f_mk_syn.htm#make-synonym-stream"><B>MAKE-SYNONYM-STREAM</B></A>)<P>
<A REL=DEFINITION HREF="../Body/t_two_wa.htm#two-way-stream"><B>TWO-WAY-STREAM</B></A> (created by <A REL=DEFINITION HREF="../Body/f_mk_two.htm#make-two-way-stream"><B>MAKE-TWO-WAY-STREAM</B></A>)<P>
<P>
The stream data types are all subtypes of type <A REL=DEFINITION HREF="../Body/t_stream.htm#stream"><B>STREAM</B></A> and are mutually<P>
exclusive. (In particular, a synonym stream is only of type <A REL=DEFINITION HREF="../Body/t_syn_st.htm#synonym-stream"><B>SYNONYM-STREAM</B></A>.)<P>
<P>
Stream Predicates:<P>
<P>
Each of these returns T if the object is of the corresponding type,<P>
and <A REL=DEFINITION HREF="../Body/a_nil.htm#nil"><B>NIL</B></A> otherwise.<P>
<P>
BROADCAST-STREAM-P, CONCATENATED-STREAM-P,<P>
ECHO-STREAM-P, FILE-STREAM-P, STRING-STREAM-P,<P>
SYNONYM-STREAM-P, TWO-WAY-STREAM-P<P>
<P>
Note that the predicates do not &quot;follow the link&quot; of a synonym<P>
stream.<P>
<P>
Stream Informational Functions:<P>
<P>
<A REL=DEFINITION HREF="../Body/f_broadc.htm#broadcast-stream-streams"><B>BROADCAST-STREAM-STREAMS</B></A> <A REL=DEFINITION HREF="../Body/t_broadc.htm#broadcast-stream"><B>broadcast-stream</B></A> ==&gt; list of streams<P>
<P>
This function returns a list of output streams that constitute<P>
all the streams the broadcast stream is broadcasting to. It is<P>
an error if the argument is not of type <A REL=DEFINITION HREF="../Body/t_broadc.htm#broadcast-stream"><B>BROADCAST-STREAM</B></A>.<P>
<P>
<A REL=DEFINITION HREF="../Body/f_conc_1.htm#concatenated-stream-streams"><B>CONCATENATED-STREAM-STREAMS</B></A> <A REL=DEFINITION HREF="../Body/t_concat.htm#concatenated-stream"><B>concatenated-stream</B></A> ==&gt; list of streams<P>
<P>
This function returns a list of input streams that constitute<P>
the ordered set of streams the concatenated stream still has to<P>
to read from, starting with the current one it is reading from.<P>
The list may be () if no more streams remain to be read.<P>
It is an error if the argument is not of type <A REL=DEFINITION HREF="../Body/t_concat.htm#concatenated-stream"><B>CONCATENATED-STREAM</B></A>.<P>
<P>
<A REL=DEFINITION HREF="../Body/f_echo_s.htm#echo-stream-input-stream"><B>ECHO-STREAM-INPUT-STREAM</B></A> <A REL=DEFINITION HREF="../Body/t_echo_s.htm#echo-stream"><B>echo-stream</B></A> ==&gt; input-stream<P>
<A REL=DEFINITION HREF="../Body/f_echo_s.htm#echo-stream-output-stream"><B>ECHO-STREAM-OUTPUT-STREAM</B></A> <A REL=DEFINITION HREF="../Body/t_echo_s.htm#echo-stream"><B>echo-stream</B></A> ==&gt; output-stream<P>
<P>
These functions return the corresponding component stream. It is<P>
an error if the argument is not of type <A REL=DEFINITION HREF="../Body/t_echo_s.htm#echo-stream"><B>ECHO-STREAM</B></A>.<P>
<P>
<A REL=DEFINITION HREF="../Body/f_syn_st.htm#synonym-stream-symbol"><B>SYNONYM-STREAM-SYMBOL</B></A> <A REL=DEFINITION HREF="../Body/t_syn_st.htm#synonym-stream"><B>synonym-stream</B></A> ==&gt; symbol<P>
<P>
This function returns the symbol whose <A REL=DEFINITION HREF="../Body/f_symb_5.htm#symbol-value"><B>SYMBOL-VALUE</B></A> the<P>
synonym stream is using. It is<P>
an error if the argument is not of type <A REL=DEFINITION HREF="../Body/t_syn_st.htm#synonym-stream"><B>SYNONYM-STREAM</B></A>.<P>
<P>
<A REL=DEFINITION HREF="../Body/f_two_wa.htm#two-way-stream-input-stream"><B>TWO-WAY-STREAM-INPUT-STREAM</B></A> <A REL=DEFINITION HREF="../Body/t_two_wa.htm#two-way-stream"><B>two-way-stream</B></A> ==&gt; input-stream<P>
<A REL=DEFINITION HREF="../Body/f_two_wa.htm#two-way-stream-output-stream"><B>TWO-WAY-STREAM-OUTPUT-STREAM</B></A> <A REL=DEFINITION HREF="../Body/t_two_wa.htm#two-way-stream"><B>two-way-stream</B></A> ==&gt; output-stream<P>
<P>
These functions return the corresponding component stream. It is<P>
an error if the argument is not of type <A REL=DEFINITION HREF="../Body/t_two_wa.htm#two-way-stream"><B>TWO-WAY-STREAM</B></A>.<P>
<P>
<P>
Proposal: <A HREF="iss327.htm">STREAM-ACCESS:ADD-TYPES-ACCESSORS</A><P>
<P>
Identical to ADD-TYPES-PREDICATES-ACCESSORS except to leave out the <P>
stream type predicates.<P>
<P>
Proposal: STREAM-ACCESS:ADD-PREDICATES-ACCESSORS<P>
<P>
Identical to ADD-TYPES-PREDICATES-ACCESSORS except to not<P>
identify new data types. The accessors act as if the types were specified<P>
(i.e., are mutually excusive).<P>
<P>
<B>Current Practice:<P>
</B><P>
VAX LISP implements ADD-TYPES-PREDICATES-ACCESSORS.<P>
We have not surveyed other implementations. <P>
<P>
<B>Cost to Implementors:<P>
</B><P>
All of the proposals are reasonably simple to implement, since the information<P>
must be present for nearly all types. <P>
<P>
<B>Cost to Users:<P>
</B><P>
The proposals are upward-compatible, and should have little impact.<P>
<P>
<B>Cost of Non-Adoption:<P>
</B><P>
The benefits would not be available in a portable fashion.<P>
<P>
<B>Benefits:<P>
</B><P>
Programs would be able to access useful information otherwise hidden.<P>
<P>
<B>Discussion:<P>
</B><P>
This issue has come up frequently, particularly dealing with SYNONYM-STREAMs.<P>
<P>
The behavior of <A REL=DEFINITION HREF="../Body/f_open_s.htm#open-stream-p"><B>OPEN-STREAM-P</B></A> on, for example, broadcast streams, might<P>
be specified in a variety of alternative ways. This specification seems the simplest.<P>
<P>
There are three proposals for voting because there was no agreement at the<P>
October X3J13 on the issue of whether types, predicates, or both should be<P>
added.<P>
<P>
There was a proposal at one time to add a new function FOLLOW-SYNONYM-STREAM<P>
which could be written as<P>
(<A REL=DEFINITION HREF="../Body/m_defun.htm#defun"><B>defun</B></A> follow-synonym-stream (x)<P>
(<A REL=DEFINITION HREF="../Body/s_if.htm#if"><B>if</B></A> (synonym-stream-p x)<P>
(follow-synonym-stream (<A REL=DEFINITION HREF="../Body/f_symb_5.htm#symbol-value"><B>symbol-value</B></A> (<A REL=DEFINITION HREF="../Body/f_syn_st.htm#synonym-stream-symbol"><B>synonym-stream-symbol</B></A> x)))<P>
x))<P>
<P>
i.e., which chases through zero or more synonym stream indirections.<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>