[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: call-with-input-file
> Perhaps the confusion is about call-with-input-file vs
with-input-from-file.
> The function call-with-input-file does not "restore the old input port"
> because it never changed the current-input-port to begin with. Instead
> it passes the input port as an argument. That is
>
> (call-with-input-file "my-file" (lambda (in) (read)))
>
> reads from the current-input-port (usually the keyboard) rather than
> from my-file.
Complete and total brain lock. I had a routine which was both reading from
a file *and* from stdin; it's a longer story, but basically I made a
mistake that caused the file reading routine to read from stdin instead,
which meant that by time I was ready to read from stdin there was nothing
left to read. I thought the problem was related to this change I had
made--moving the body of with-input-from-file to call-with-input-file--but
it wasn't, etc.
Oops. Sorry.