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

208 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 STANDARD-INPUT-INITIAL-BINDING 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/iss322_w.htm">
<LINK REL=UP HREF="../Issues/iss323.htm">
<LINK REL=NEXT HREF="../Issues/iss324_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/iss322_w.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Previous]" SRC="../Graphics/Prev.gif" ALIGN=Bottom></A><A REL=UP HREF="../Issues/iss323.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Up]" SRC="../Graphics/Up.gif" ALIGN=Bottom></A><A REL=NEXT HREF="../Issues/iss324_w.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Next]" SRC="../Graphics/Next.gif" ALIGN=Bottom></A></H1>
<HR>
<H2>Issue STANDARD-INPUT-INITIAL-BINDING Writeup</H2>
<PRE><B>Status:</B> Passed, Jan 89 X3J13<P>
<B>Issue:</B> <A HREF="iss323.htm">STANDARD-INPUT-INITIAL-BINDING</A><P>
<B>References:</B> Standard streams (pp. 327-329)<P>
<B>Category:</B> CHANGE<P>
<B>Edit history:</B> Version 1 by Pierson and Haflich 1/19/87<P>
Version 2 by Pierson 2/29/88<P>
Version 3 by Pierson 5/23/88, per comments by Moon<P>
Version 4 by Pierson 5/26/88, clean up<P>
Version 5 by Pierson 6/28/88, simple design per Masinter<P>
Version 6 by Pierson 7/ 5/88, clean up and split issue<P>
Version 7 by Pierson 7/ 8/88, clean up per Pitman<P>
Version 8 by Pierson 7/ 8/88, yet more clean up<P>
<P>
<B>Problem description:<P>
</B><P>
CLtL requires that <A REL=DEFINITION HREF="../Body/v_debug_.htm#STstandard-inputST"><B>*STANDARD-INPUT*</B></A>, <A REL=DEFINITION HREF="../Body/v_debug_.htm#STstandard-outputST"><B>*STANDARD-OUTPUT*</B></A>,<P>
<A REL=DEFINITION HREF="../Body/v_debug_.htm#STerror-outputST"><B>*ERROR-OUTPUT*</B></A>, <A REL=DEFINITION HREF="../Body/v_debug_.htm#STtrace-outputST"><B>*TRACE-OUTPUT*</B></A>, <A REL=DEFINITION HREF="../Body/v_debug_.htm#STquery-ioST"><B>*QUERY-IO*</B></A>, and <A REL=DEFINITION HREF="../Body/v_debug_.htm#STdebug-ioST"><B>*DEBUG-IO*</B></A> are<P>
initially bound to synonym streams to <A REL=DEFINITION HREF="../Body/v_termin.htm#STterminal-ioST"><B>*TERMINAL-IO*</B></A>. This requirement<P>
hampers the integration of Common Lisp with many existing and<P>
potential operating environments.<P>
<P>
For example, a Unix implementation is currently unable to legally<P>
support Unix <A REL=DEFINITION HREF="../Body/07_ffb.htm#standard"><B>standard</B></A> error output even though Common Lisp defines<P>
<A REL=DEFINITION HREF="../Body/v_debug_.htm#STerror-outputST"><B>*ERROR-OUTPUT*</B></A> because <A REL=DEFINITION HREF="../Body/v_debug_.htm#STerror-outputST"><B>*ERROR-OUTPUT*</B></A> is required to start out bound<P>
to the same stream as <A REL=DEFINITION HREF="../Body/v_debug_.htm#STstandard-outputST"><B>*STANDARD-OUTPUT*</B></A>. A workstation environnment<P>
which provides stream access to windows as an extension is currently<P>
forbidden to make <A REL=DEFINITION HREF="../Body/m_tracec.htm#trace"><B>trace</B></A> output appear in a separate window by default<P>
because <A REL=DEFINITION HREF="../Body/v_debug_.htm#STtrace-outputST"><B>*TRACE-OUTPUT*</B></A> is required to start out bound to the same<P>
stream as <A REL=DEFINITION HREF="../Body/v_debug_.htm#STstandard-outputST"><B>*STANDARD-OUTPUT*</B></A>.<P>
<P>
<B>Proposal (STANDARD-INPUT-INITIAL-BINDING:DEFINED-CONTRACTS):<P>
</B><P>
A Common Lisp implementation is required to <A REL=DEFINITION HREF="../Body/f_provid.htm#provide"><B>provide</B></A> the following<P>
initial streams. Each initial stream has a specific purpose as<P>
defined in CLtL. This proposal redefines the initial bindings of<P>
the streams and leaves the rest of the CLtL description unchanged.<P>
<P>
<A REL=DEFINITION HREF="../Body/v_termin.htm#STterminal-ioST"><B>*TERMINAL-IO*</B></A><P>
<A REL=DEFINITION HREF="../Body/v_debug_.htm#STstandard-inputST"><B>*STANDARD-INPUT*</B></A><P>
<A REL=DEFINITION HREF="../Body/v_debug_.htm#STstandard-outputST"><B>*STANDARD-OUTPUT*</B></A><P>
<A REL=DEFINITION HREF="../Body/v_debug_.htm#STerror-outputST"><B>*ERROR-OUTPUT*</B></A><P>
<A REL=DEFINITION HREF="../Body/v_debug_.htm#STtrace-outputST"><B>*TRACE-OUTPUT*</B></A><P>
<A REL=DEFINITION HREF="../Body/v_debug_.htm#STquery-ioST"><B>*QUERY-IO*</B></A><P>
<A REL=DEFINITION HREF="../Body/v_debug_.htm#STdebug-ioST"><B>*DEBUG-IO*</B></A><P>
<P>
The initial bindings of these variables are undefined except<P>
that:<P>
1. They are all initially bound to open streams.<P>
2. The streams must support input and/or output as<P>
indicated by the variable name.<P>
3. None of the <A REL=DEFINITION HREF="../Body/07_ffb.htm#standard"><B>standard</B></A> streams (including <A REL=DEFINITION HREF="../Body/v_termin.htm#STterminal-ioST"><B>*TERMINAL-IO*</B></A>)<P>
may be directed by synonym streams to another of these<P>
stream variables (except <A REL=DEFINITION HREF="../Body/v_termin.htm#STterminal-ioST"><B>*TERMINAL-IO*</B></A>), whether<P>
directly or by indirection via some composite stream<P>
such as a two way stream with one of the arms being a<P>
synonym stream.<P>
4. Any or all of these streams may be synonyms for the<P>
common implementation dependent stream. For example,<P>
in an interactive Common Lisp invocation running on a<P>
character terminal, all of the streams mentioned here<P>
might be synonym streams (or two-way streams to synonym<P>
streams) to a pair of hidden terminal input/output<P>
streams maintained by the implementation.<P>
<P>
The intent of the above rules is to ensure that it is always<P>
safe to bind any of the above variables to another of the<P>
above variables without unduly restricting implementation<P>
flexibility.<P>
<P>
<P>
<B>Examples:<P>
</B><P>
(<A REL=DEFINITION HREF="../Body/s_progn.htm#progn"><B>PROGN</B></A><P>
(<A REL=DEFINITION HREF="../Body/f_wr_pr.htm#print"><B>PRINT</B></A> &quot;Output&quot; <A REL=DEFINITION HREF="../Body/v_debug_.htm#STstandard-outputST"><B>*STANDARD-OUTPUT*</B></A>)<P>
(<A REL=DEFINITION HREF="../Body/f_wr_pr.htm#print"><B>PRINT</B></A> &quot;Error&quot; <A REL=DEFINITION HREF="../Body/v_debug_.htm#STerror-outputST"><B>*ERROR-OUTPUT*</B></A>))<P>
<P>
In current Common Lisp will write:<P>
------<P>
Output<P>
Error<P>
------<P>
<P>
With proposal *might* write:<P>
------<P>
Output<P>
------<P>
and &quot;Error&quot; appears somewhere else.<P>
<P>
<P>
(<A REL=DEFINITION HREF="../Body/s_let_l.htm#let"><B>LET</B></A> ((<A REL=DEFINITION HREF="../Body/v_debug_.htm#STstandard-outputST"><B>*STANDARD-OUTPUT*</B></A> <A REL=DEFINITION HREF="../Body/v_debug_.htm#STdebug-ioST"><B>*DEBUG-IO*</B></A>))<P>
...)<P>
<P>
In current Common Lisp: <P>
Might cause a circular stream reference if <A REL=DEFINITION HREF="../Body/v_debug_.htm#STdebug-ioST"><B>*DEBUG-IO*</B></A> was<P>
bound to a two-way stream made up of synonym streams to<P>
<A REL=DEFINITION HREF="../Body/v_debug_.htm#STstandard-inputST"><B>*STANDARD-INPUT*</B></A> and <A REL=DEFINITION HREF="../Body/v_debug_.htm#STstandard-outputST"><B>*STANDARD-OUTPUT*</B></A>.<P>
<P>
With this proposal:<P>
Would be guaranteed not to cause a circular stream reference<P>
unless the initial value of <A REL=DEFINITION HREF="../Body/v_debug_.htm#STdebug-ioST"><B>*DEBUG-IO*</B></A> had been changed to a value<P>
that did not conform the restrictions in this proposal. While no<P>
Common Lisp implementation should do this, a user program might.<P>
<P>
<P>
(<A REL=DEFINITION HREF="../Body/s_let_l.htm#let"><B>LET</B></A> ((<A REL=DEFINITION HREF="../Body/v_debug_.htm#STstandard-inputST"><B>*STANDARD-INPUT*</B></A> <A REL=DEFINITION HREF="../Body/v_termin.htm#STterminal-ioST"><B>*TERMINAL-IO*</B></A>)<P>
(<A REL=DEFINITION HREF="../Body/v_debug_.htm#STstandard-outputST"><B>*STANDARD-OUTPUT*</B></A> <A REL=DEFINITION HREF="../Body/v_termin.htm#STterminal-ioST"><B>*TERMINAL-IO*</B></A>))<P>
...)<P>
<P>
In current Common Lisp: <P>
Might cause a circular stream reference because <A REL=DEFINITION HREF="../Body/v_termin.htm#STterminal-ioST"><B>*TERMINAL-IO*</B></A> was<P>
bound to a two-way stream made up of synonym streams to<P>
<A REL=DEFINITION HREF="../Body/v_debug_.htm#STstandard-inputST"><B>*STANDARD-INPUT*</B></A> and <A REL=DEFINITION HREF="../Body/v_debug_.htm#STstandard-outputST"><B>*STANDARD-OUTPUT*</B></A>.<P>
<P>
With this proposal:<P>
Would be guaranteed not to cause a circular stream reference.<P>
<P>
<P>
<B>Rationale:<P>
</B><P>
This proposal attempts to <A REL=DEFINITION HREF="../Body/f_provid.htm#provide"><B>provide</B></A> a balance between over-specifying<P>
behavior to the point that Lisp programs can't behave like other<P>
programs in conventional operating systems and providing enough<P>
specification that Common Lisp programs can perform portable input and<P>
output.<P>
<P>
<B>Current practice:<P>
</B><P>
Lucid binds <A REL=DEFINITION HREF="../Body/v_termin.htm#STterminal-ioST"><B>*TERMINAL-IO*</B></A> to a special internal stream type. Franz<P>
binds <A REL=DEFINITION HREF="../Body/v_termin.htm#STterminal-ioST"><B>*TERMINAL-IO*</B></A> to a special internal stream type for terminal<P>
streams which reads from Unix <A REL=DEFINITION HREF="../Body/07_ffb.htm#standard"><B>standard</B></A> input and writes to Unix<P>
<A REL=DEFINITION HREF="../Body/07_ffb.htm#standard"><B>standard</B></A> output. KCL binds <A REL=DEFINITION HREF="../Body/v_termin.htm#STterminal-ioST"><B>*TERMINAL-IO*</B></A> to a <A REL=DEFINITION HREF="../Body/07_ffb.htm#standard"><B>standard</B></A> <A REL=DEFINITION HREF="../Body/t_two_wa.htm#two-way-stream"><B>two-way-stream</B></A><P>
with input from Unix <A REL=DEFINITION HREF="../Body/07_ffb.htm#standard"><B>standard</B></A> input and output to Unix <A REL=DEFINITION HREF="../Body/07_ffb.htm#standard"><B>standard</B></A><P>
output. Symbolics Genera binds <A REL=DEFINITION HREF="../Body/v_termin.htm#STterminal-ioST"><B>*TERMINAL-IO*</B></A> as appropriate for each<P>
process, usually to a window for interactive applications or to a<P>
stream which will conjure an interaction window on demand for<P>
background tasks.<P>
<P>
<B>Cost to Implementors:<P>
</B><P>
All implementations will have to change to some degree but the changes<P>
will probably be simple and localized. All known implementations<P>
already support the underlying streams required to implement this<P>
proposal.<P>
<P>
<B>Cost to Users:<P>
</B><P>
User code which depends on the strict binding hierarchy in CLtL may<P>
have to change. <P>
<P>
<B>Cost of non-Adoption:<P>
</B><P>
It will continue to be difficult or impossible to integrate portable<P>
Common Lisp progams in conventional operating system environments.<P>
Many implementations will have to continue to choose between<P>
conforming to the <A REL=DEFINITION HREF="../Body/07_ffb.htm#standard"><B>standard</B></A> and providing a superior user environment.<P>
<P>
<B>Benefits:<P>
</B><P>
Implementations will be more able to match their IO behavior to their<P>
environment and their user's expectations.<P>
<P>
<B>Aesthetics:<P>
</B><P>
Improved because this area becomes better defined.<P>
<P>
<B>Discussion:<P>
</B><P>
Moon says that <A REL=DEFINITION HREF="../Body/v_termin.htm#STterminal-ioST"><B>*TERMINAL-IO*</B></A> (and, by extension, <A REL=DEFINITION HREF="../Body/v_debug_.htm#STquery-ioST"><B>*QUERY-IO*</B></A>, and<P>
<A REL=DEFINITION HREF="../Body/v_debug_.htm#STdebug-ioST"><B>*DEBUG-IO*</B></A>) should fail to work in a non-interactive environment where<P>
nothing like a terminal exists. This proposal fails to address this.<P>
<P>
Masinter notes that:<P>
``In many multi-processing multi-window environments,<P>
the &quot;initial binding&quot; for <A REL=DEFINITION HREF="../Body/v_debug_.htm#STstandard-inputST"><B>*STANDARD-INPUT*</B></A>, *QUERY-INPUT*<P>
differs for each process.'' <P>
<P>
Pierson and Pitman support <A HREF="iss323.htm">STANDARD-INPUT-INITIAL-BINDING:DEFINED-CONTRACTS</A>.<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>