[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.
Paul
On Fri, Oct 19, 2001 at 10:03:31AM -0600, Matthew Flatt wrote:
> Quoting MichaelL@frogware.com:
> > This may be as intended, but in case it's not: with-input-from-file
> > restores the old input port, but call-with-input-file doesn't. It seems
> > like they both should. (I've looked at the source, so I understand why
> > it's happening; I'm just asking whether or not the two really should
> > behave differently.)
>
> Arguably, `with-input-from-file' shouldn't restore the current input
> port on exit unless it's replacing the one put there by
> `with-input-from-file' on entry. But it currently behaves in a way
> that's consistent with `parameterize' expressions in general, so I'm
> inclined to leave it as-in.
>
> In any case, the current behavior should be better documented.
>
> Matthew