User Tools



  • clear-input &optional input-streamnil

Arguments and Values


Clears any available input from input-stream.

If clear-input does not make sense for input-stream, then clear-input does nothing.


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 '>) (when zzz (sleep zzz)) (print '») (when clear-p (clear-input)) (read))))


> 10

20 </o>

→ (10 20)

(read-sleepily t)

> 10

20 </o>

→ (10 20)

(read-sleepily t 10)

> 10

20 ; Some implementations won't echo typeahead here.
30 </o>

→ (10 30) </blockquote>

====Side Effects==== The input-stream is modified.

====Affected By==== *standard-input*

====Exceptional Situations==== Should signal an error of type type-error if input-stream is not a stream designator.

====See Also====

====Notes==== None.