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

137 lines
7.9 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-CAPABILITIES 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/iss327_w.htm">
<LINK REL=UP HREF="../Issues/iss328.htm">
<LINK REL=NEXT HREF="../Issues/iss329_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/iss327_w.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Previous]" SRC="../Graphics/Prev.gif" ALIGN=Bottom></A><A REL=UP HREF="../Issues/iss328.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Up]" SRC="../Graphics/Up.gif" ALIGN=Bottom></A><A REL=NEXT HREF="../Issues/iss329_w.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Next]" SRC="../Graphics/Next.gif" ALIGN=Bottom></A></H1>
<HR>
<H2>Issue STREAM-CAPABILITIES Writeup</H2>
<PRE><B>Issue:</B> <A HREF="iss328.htm">STREAM-CAPABILITIES</A><P>
<B>References:</B> Standard streams (pp. 327-329)<P>
<B>Category:</B> ADDITION<P>
<B>Edit history:</B> Version 1 by Pierson 5-Jul-88, add redesign per Pitman<P>
Version 2 by Moon, 10-May-89, remove controversial parts<P>
Version 3 by Moon, 12-May-89, improve wording and examples<P>
<P>
<B>Problem description:<P>
</B><P>
Programs cannot currently distinguish between interactive use and batch<P>
(or background) use without using implementation-dependent extensions.<P>
For example, there is currently no way to tell whether it is useful to<P>
ask a question when an unexpected situation is encountered.<P>
<P>
Note: earlier versions of this issue tried to solve another problem<P>
as well. See discussion section.<P>
<P>
<B>Proposal (STREAM-CAPABILITIES:INTERACTIVE-STREAM-P):<P>
</B><P>
Add the following function:<P>
<P>
<A REL=DEFINITION HREF="../Body/f_intera.htm#interactive-stream-p"><B>INTERACTIVE-STREAM-P</B></A> stream<P>
<P>
Returns T if the stream is interactive, otherwise <A REL=DEFINITION HREF="../Body/a_nil.htm#nil"><B>NIL</B></A>. Signals<P>
an error of type <A REL=DEFINITION HREF="../Body/e_tp_err.htm#type-error"><B>TYPE-ERROR</B></A> if the argument is not a stream.<P>
<P>
The precise meaning of <A REL=DEFINITION HREF="../Body/f_intera.htm#interactive-stream-p"><B>INTERACTIVE-STREAM-P</B></A> is implementation<P>
dependent, and may depend on the underlying operating system. However<P>
the general intent is to distinguish between interactive and batch (or<P>
background or command-file) operations.<P>
<P>
Some examples of the things that might identify a stream as interactive<P>
include:<P>
1. The stream is connected to a person (or equivalent) in<P>
such a way that the program can prompt for information and<P>
expect to receive different input depending on the prompt.<P>
2. The program is expected to prompt for input and support<P>
&quot;normal input editing&quot;.<P>
3. <A REL=DEFINITION HREF="../Body/f_rd_cha.htm#read-char"><B>READ-CHAR</B></A> might hang waiting for the user to type something<P>
instead of quickly returning a character or EOF.<P>
<P>
<A REL=DEFINITION HREF="../Body/v_termin.htm#STterminal-ioST"><B>*TERMINAL-IO*</B></A> might or might not be interactive.<P>
<P>
<B>Examples:<P>
</B><P>
(<A REL=DEFINITION HREF="../Body/m_when_.htm#when"><B>when</B></A> (&gt; measured limit)<P>
(<A REL=DEFINITION HREF="../Body/s_let_l.htm#let"><B>let</B></A> ((<A REL=DEFINITION HREF="../Body/a_error.htm#error"><B>error</B></A> (<A REL=DEFINITION HREF="../Body/f_floorc.htm#round"><B>round</B></A> (* (- measured limit) 100)<P>
limit)))<P>
(<A REL=DEFINITION HREF="../Body/m_when_.htm#unless"><B>unless</B></A> (<A REL=DEFINITION HREF="../Body/s_if.htm#if"><B>if</B></A> (<A REL=DEFINITION HREF="../Body/f_intera.htm#interactive-stream-p"><B>interactive-stream-p</B></A> <A REL=DEFINITION HREF="../Body/v_debug_.htm#STquery-ioST"><B>*query-io*</B></A>)<P>
(<A REL=DEFINITION HREF="../Body/f_y_or_n.htm#yes-or-no-p"><B>yes-or-no-p</B></A> &quot;The frammis is out of tolerance by ~D%.~@<P>
Is it safe to proceed? &quot; <A REL=DEFINITION HREF="../Body/a_error.htm#error"><B>error</B></A>)<P>
(&lt; <A REL=DEFINITION HREF="../Body/a_error.htm#error"><B>error</B></A> 15)) ;15% is acceptable<P>
(<A REL=DEFINITION HREF="../Body/a_error.htm#error"><B>error</B></A> &quot;The frammis is out of tolerance by ~D%.&quot; <A REL=DEFINITION HREF="../Body/a_error.htm#error"><B>error</B></A>))))<P>
<P>
<B>Rationale:<P>
</B><P>
<A REL=DEFINITION HREF="../Body/f_intera.htm#interactive-stream-p"><B>INTERACTIVE-STREAM-P</B></A> has been proposed several times and is clearly<P>
needed by any program that alters its behavior depending on whether<P>
it is interacting with a user or running in a &quot;batch&quot; mode.<P>
<P>
<B>Current practice:<P>
</B><P>
Most implementations have this feature already, often under a<P>
different name.<P>
<P>
<B>Cost to Implementors:<P>
</B><P>
Implementations will have to support this new function. Correct support<P>
will <A REL=DEFINITION HREF="../Body/f_provid.htm#require"><B>require</B></A> some thought for each operating system supported.<P>
<P>
<B>Cost to Users:<P>
</B><P>
None, this is an upward-compatible extension.<P>
<P>
<B>Cost of non-adoption:<P>
</B><P>
Less featureful language. <P>
<P>
<B>Performance impact:<P>
</B><P>
None.<P>
<P>
<B>Benefits:<P>
</B><P>
More featureful language.<P>
<P>
<B>Esthetics:<P>
</B><P>
More featureful language.<P>
<P>
<B>Discussion:<P>
</B><P>
It's not possible to make a specific definition of &quot;interactive&quot; that<P>
applies to all operating systems, we concluded from earlier discussion.<P>
However, &quot;everyone knows&quot; appoximately what it means. Hence the idea<P>
of describing it by example rather than defining it.<P>
<P>
Note that some proposed features for telling whether two streams are<P>
connected to the same source or sink of information have been removed<P>
from this version of the proposal. These were the functions<P>
STREAM-SAME-SOURCE-P, STREAM-SAME-DESTINATION-P, STREAM-SOURCE-ID-LIST,<P>
and STREAM-DESTINATION-ID-LIST. These could be revived in another<P>
proposal if desired, but Moon thought <A REL=DEFINITION HREF="../Body/f_intera.htm#interactive-stream-p"><B>INTERACTIVE-STREAM-P</B></A> was<P>
important and didn't want it to be lost due to controversy over these <P>
unrelated functions.<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>