with-input-from-file -- r7rs Definition procedure;
with-input-from-file (from vonuvoli);Procedure variants:
((path-string procedure-0) -> (any))
path-string;procedure-0;any;scheme:file -- (scheme file);scheme -- (scheme);(with-input-from-file string thunk) (with-output-to-file string thunk)The file is opened for input or output as if by
open-input-fileoropen-output-file, and the new port is made to be the value returned bycurrent-input-portorcurrent-output-port(as used by(read),(write obj), and so forth). Thethunkis then called with no arguments. When thethunkreturns, the port is closed and the previous default is restored. It is an error ifthunkdoes not accept zero arguments. Both procedures return the values yielded bythunk. If an escape procedure is used to escape from the continuation of these procedures, they behave exactly as if the current input or output port had been bound dynamically withparameterize.
The text herein was sourced and adapted as described in the "R7RS attribution of various text snippets" appendix.