312 lines
No EOL
5.9 KiB
HTML
312 lines
No EOL
5.9 KiB
HTML
<!DOCTYPE HTML>
|
|
<HTML LANG="en-us"
|
|
><HEAD
|
|
><TITLE
|
|
>clear-input | Common Lisp Nova Spec</TITLE
|
|
><META CHARSET="US-ASCII"
|
|
><LINK REL="canonical" HREF="f_clear-input.html"
|
|
><LINK REL="next" HREF="f_finish-output.html" TYPE="text/html" TITLE="finish-output, force-output, clear-output"
|
|
><LINK REL="prev" HREF="f_listen.html" TYPE="text/html" TITLE="listen"
|
|
><LINK REL="up" HREF="21_2_Streams_Dictionary.html" TYPE="text/html" TITLE="21.2 Streams Dictionary"
|
|
><LINK REL="start" HREF="index.html" TYPE="text/html" TITLE="Common Lisp Nova Spec"
|
|
><META NAME="VIEWPORT" CONTENT="width=device-width, initial-scale=1.0"
|
|
><LINK REL="STYLESHEET" HREF="dpans.css%3F3909942064.css"
|
|
><SCRIPT SRC="dpans.js%3F3909942064"
|
|
></SCRIPT
|
|
><SCRIPT SRC="apropos.js%3F3909942064"
|
|
></SCRIPT
|
|
></HEAD
|
|
><BODY
|
|
><DIV
|
|
><DIV CLASS="topnav"
|
|
><DIV CLASS="breadcrumb"
|
|
><SPAN CLASS="breadcrumb-item"
|
|
><A HREF="index.html"
|
|
>Common Lisp Nova Spec</A
|
|
></SPAN
|
|
> <SPAN CLASS="breadcrumb-item"
|
|
>→ <A HREF="21_Streams.html"
|
|
>21. Streams</A
|
|
></SPAN
|
|
> <SPAN CLASS="breadcrumb-item"
|
|
>→ <A HREF="21_2_Streams_Dictionary.html"
|
|
>21.2 Streams Dictionary</A
|
|
></SPAN
|
|
> <SPAN CLASS="breadcrumb-item"
|
|
>→ <A HREF="f_clear-input.html"
|
|
>clear-input</A
|
|
></SPAN
|
|
></DIV
|
|
><DIV CLASS="apropos"
|
|
><DIV CLASS="apropos-io"
|
|
><A HREF="f_listen.html" CLASS="prev"
|
|
>←</A
|
|
><SPAN ID="apropos-label"
|
|
>Apropos </SPAN
|
|
><INPUT ID="apropos" AUTOFOCUS="AUTOFOCUS" PLACEHOLDER="Type here to search" ONINPUT="aproposInput(this);" ONKEYUP="aproposKeyup(event);" ONCHANGE="aproposChange(this);" ONFOCUS="aproposFocus(this);" ONFOCUSOUT="aproposFocusout(this);"
|
|
><A HREF="f_finish-output.html" CLASS="next"
|
|
>→</A
|
|
></DIV
|
|
><DIV ID="apropos-res"
|
|
></DIV
|
|
></DIV
|
|
></DIV
|
|
><DIV CLASS="matter"
|
|
><DIV CLASS="com"
|
|
><DIV CLASS="begincom"
|
|
><HR
|
|
><TABLE WIDTH="100%" CELLSPACING="0" CELLPADDING="0"
|
|
><TR
|
|
><TD ALIGN="LEFT" VALIGN="BASELINE" WIDTH="100%" CLASS="name"
|
|
><SPAN CLASS="idx" DATA-KIND="idxref" DATA-TERM="clear-input"
|
|
></SPAN
|
|
><B
|
|
>clear-input</B
|
|
></TD
|
|
><TD ALIGN="RIGHT" VALIGN="BASELINE" WIDTH="0" NOWRAP="NOWRAP" CLASS="ftype"
|
|
><I
|
|
>Function</I
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
><HR
|
|
></DIV
|
|
><UL CLASS="subtoc"
|
|
></UL
|
|
><DL
|
|
><DT
|
|
><B
|
|
>Syntax</B
|
|
></DT
|
|
><DD
|
|
><P CLASS="j"
|
|
><B
|
|
>clear-input</B
|
|
> <SPAN CLASS="cmtt"
|
|
>&optional</SPAN
|
|
> <SPAN CLASS="cmssi"
|
|
>input-stream</SPAN
|
|
> <SPAN CLASS="arrow"
|
|
>→</SPAN
|
|
> <SPAN CLASS="misc"
|
|
><B
|
|
>nil</B
|
|
></SPAN
|
|
></P
|
|
></DD
|
|
><DT
|
|
><B
|
|
>Arguments and Values</B
|
|
></DT
|
|
><DD
|
|
><P CLASS="j"
|
|
><VAR CLASS="param"
|
|
>input-stream</VAR
|
|
> — an <A HREF="26_1_Glossary.html#input"
|
|
><EM CLASS="term"
|
|
>input</EM
|
|
></A
|
|
> <A HREF="26_1_Glossary.html#stream_designator"
|
|
><EM CLASS="term"
|
|
>stream designator</EM
|
|
></A
|
|
>. The default is <A HREF="26_1_Glossary.html#standard_input"
|
|
><EM CLASS="term"
|
|
>standard input</EM
|
|
></A
|
|
>.</P
|
|
></DD
|
|
><DT
|
|
><B
|
|
>Description</B
|
|
></DT
|
|
><DD
|
|
><P CLASS="j"
|
|
>Clears any available input from <VAR CLASS="param"
|
|
>input-stream</VAR
|
|
>. </P
|
|
><P CLASS="j"
|
|
>If <A HREF="f_clear-input.html" CLASS="funref"
|
|
><B
|
|
>clear-input</B
|
|
></A
|
|
> does not make sense for <VAR CLASS="param"
|
|
>input-stream</VAR
|
|
>, then <A HREF="f_clear-input.html" CLASS="funref"
|
|
><B
|
|
>clear-input</B
|
|
></A
|
|
> does nothing.</P
|
|
></DD
|
|
><DT
|
|
><B
|
|
>Examples</B
|
|
></DT
|
|
><DD
|
|
><PRE CLASS="screen"
|
|
>;; The exact I/O behavior of this example might vary from implementation
|
|
;; to implementation depending on the kind of interactive buffering that
|
|
;; occurs. (The call to SLEEP here is intended to help even out the
|
|
;; differences in implementations which do not do line-at-a-time buffering.)
|
|
|
|
(defun read-sleepily (&optional (clear-p nil) (zzz 0))
|
|
(list (progn (print '>) (read))
|
|
;; Note that input typed within the first ZZZ seconds
|
|
;; will be discarded.
|
|
(progn (print '>)
|
|
(if zzz (sleep zzz))
|
|
(print '>>)
|
|
(if clear-p (clear-input))
|
|
(read))))
|
|
|
|
(read-sleepily)
|
|
<SPAN CLASS="cmr"
|
|
>⊳</SPAN
|
|
> > <U CLASS="underline"
|
|
><SPAN CLASS="cmtt"
|
|
>10</SPAN
|
|
></U
|
|
>
|
|
<SPAN CLASS="cmr"
|
|
>⊳</SPAN
|
|
> >
|
|
<SPAN CLASS="cmr"
|
|
>⊳</SPAN
|
|
> >> <U CLASS="underline"
|
|
><SPAN CLASS="cmtt"
|
|
>20</SPAN
|
|
></U
|
|
>
|
|
<SPAN CLASS="cmsy"
|
|
><SPAN CLASS="arrow"
|
|
>→</SPAN
|
|
></SPAN
|
|
> (10 20)
|
|
|
|
(read-sleepily t)
|
|
<SPAN CLASS="cmr"
|
|
>⊳</SPAN
|
|
> > <U CLASS="underline"
|
|
><SPAN CLASS="cmtt"
|
|
>10</SPAN
|
|
></U
|
|
>
|
|
<SPAN CLASS="cmr"
|
|
>⊳</SPAN
|
|
> >
|
|
<SPAN CLASS="cmr"
|
|
>⊳</SPAN
|
|
> >> <U CLASS="underline"
|
|
><SPAN CLASS="cmtt"
|
|
>20</SPAN
|
|
></U
|
|
>
|
|
<SPAN CLASS="cmsy"
|
|
><SPAN CLASS="arrow"
|
|
>→</SPAN
|
|
></SPAN
|
|
> (10 20)
|
|
|
|
(read-sleepily t 10)
|
|
<SPAN CLASS="cmr"
|
|
>⊳</SPAN
|
|
> > <U CLASS="underline"
|
|
><SPAN CLASS="cmtt"
|
|
>10</SPAN
|
|
></U
|
|
>
|
|
<SPAN CLASS="cmr"
|
|
>⊳</SPAN
|
|
> > <U CLASS="underline"
|
|
><SPAN CLASS="cmtt"
|
|
>20</SPAN
|
|
></U
|
|
> ; Some implementations won't echo typeahead here.
|
|
<SPAN CLASS="cmr"
|
|
>⊳</SPAN
|
|
> >> <U CLASS="underline"
|
|
><SPAN CLASS="cmtt"
|
|
>30</SPAN
|
|
></U
|
|
>
|
|
<SPAN CLASS="cmsy"
|
|
><SPAN CLASS="arrow"
|
|
>→</SPAN
|
|
></SPAN
|
|
> (10 30)</PRE
|
|
></DD
|
|
><DT
|
|
><B
|
|
>Side Effects</B
|
|
></DT
|
|
><DD
|
|
><P CLASS="j"
|
|
>The <VAR CLASS="param"
|
|
>input-stream</VAR
|
|
> is modified.</P
|
|
></DD
|
|
><DT
|
|
><B
|
|
>Affected By</B
|
|
></DT
|
|
><DD
|
|
><P CLASS="j"
|
|
><A HREF="v_debug-io.html" CLASS="varref"
|
|
><B
|
|
>*standard-input*</B
|
|
></A
|
|
></P
|
|
></DD
|
|
><DT
|
|
><B
|
|
>Exceptional Situations</B
|
|
></DT
|
|
><DD
|
|
><P CLASS="j"
|
|
>Should signal an error of <A HREF="26_1_Glossary.html#type"
|
|
><EM CLASS="term"
|
|
>type</EM
|
|
></A
|
|
> <A HREF="t_type-error.html" CLASS="typeref"
|
|
><B
|
|
>type-error</B
|
|
></A
|
|
> if <VAR CLASS="param"
|
|
>input-stream</VAR
|
|
> is not a <A HREF="26_1_Glossary.html#stream_designator"
|
|
><EM CLASS="term"
|
|
>stream designator</EM
|
|
></A
|
|
>.</P
|
|
></DD
|
|
><DT
|
|
><B
|
|
>See Also</B
|
|
></DT
|
|
><DD
|
|
><P CLASS="j"
|
|
><A HREF="f_finish-output.html" CLASS="funref"
|
|
><B
|
|
>clear-output</B
|
|
></A
|
|
></P
|
|
></DD
|
|
></DL
|
|
></DIV
|
|
></DIV
|
|
><DIV CLASS="footer"
|
|
><DIV CLASS="btmnav"
|
|
><A HREF="f_listen.html" CLASS="prev"
|
|
>←</A
|
|
><A HREF="f_finish-output.html" CLASS="next"
|
|
>→</A
|
|
></DIV
|
|
><DIV CLASS="trail"
|
|
>Conversion to HTML copyright 2023 by Gilbert Baumann</DIV
|
|
></DIV
|
|
></DIV
|
|
><SCRIPT
|
|
>domReady();</SCRIPT
|
|
></BODY
|
|
></HTML
|
|
> |