[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]


From: Alex Shinn
Subject: drain-input
Date: 24 Aug 2001 11:11:05 -0400
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.0.104

Could someone explain the purpose of drain-input?  My first impression
was that it would read all remaining input from an input port, so that
you could do the following:

(define (file-contents file)
  (call-with-input-file file drain-input))

but this doesn't work, and on playing with drain-input it seems to be
working more with the internal port buffering.  For example:

(define p (open-input-file foo))   ; str is
(define str (drain-input p))       ; ""
(unread-char #\x p)
(set! str (drain-input p))         ; "x"
(set! str (drain-input p))         ; ""
(peek-char p)
(set! str (drain-input p))         ; entire contents of foo

Is this the correct behaviour?  What is drain-input really doing?

Alex Shinn <address@hidden>

reply via email to

[Prev in Thread] Current Thread [Next in Thread]