--- scheme-io.texi.~1.12.~ 2003-06-01 10:18:51.000000000 +1000 +++ scheme-io.texi 2003-06-12 10:45:48.000000000 +1000 @@ -301,23 +301,15 @@ descriptors. @end deffn address@hidden close-input-port @deffn {Scheme Procedure} close-input-port port address@hidden {Scheme Procedure} close-output-port port @deffnx {C Function} scm_close_input_port (port) -Close the specified input port object. The routine has no effect if -the file has already been closed. An exception may be raised if an -error occurs. The value returned is unspecified. - -See also @ref{Ports and File Descriptors, close}, for a procedure -which can close file descriptors. address@hidden deffn - address@hidden close-output-port address@hidden {Scheme Procedure} close-output-port port @deffnx {C Function} scm_close_output_port (port) -Close the specified output port object. The routine has no effect if -the file has already been closed. An exception may be raised if an -error occurs. The value returned is unspecified. address@hidden close-input-port address@hidden close-output-port +Close the specified input or output @var{port}. An exception may be +raised if an error occurs while closing. If @var{port} is already +closed, nothing is done. The return value is unspecified. See also @ref{Ports and File Descriptors, close}, for a procedure which can close file descriptors. @@ -709,68 +701,42 @@ @end smalllisp @end deffn address@hidden {Scheme Procedure} call-with-input-file filename proc address@hidden {Scheme Procedure} call-with-output-file filename proc @rnindex call-with-input-file address@hidden {Scheme Procedure} call-with-input-file file proc address@hidden should be a procedure of one argument, and @var{file} should -be a string naming a file. The file must already exist. These -procedures call @var{proc} with one argument: the port obtained by -opening the named file for input or output. If the file cannot be -opened, an error is signalled. If the procedure returns, then the port -is closed automatically and the value yielded by the procedure is -returned. If the procedure does not return, then the port will not be -closed automatically unless it is possible to prove that the port will -never again be used for a read or write operation. address@hidden deffn - @rnindex call-with-output-file address@hidden {Scheme Procedure} call-with-output-file file proc address@hidden should be a procedure of one argument, and @var{file} should -be a string naming a file. The behaviour is unspecified if the file -already exists. These procedures call @var{proc} with one argument: the -port obtained by opening the named file for input or output. If the -file cannot be opened, an error is signalled. If the procedure returns, -then the port is closed automatically and the value yielded by the -procedure is returned. If the procedure does not return, then the port -will not be closed automatically unless it is possible to prove that the -port will never again be used for a read or write operation. address@hidden deffn - +Open @var{filename} for input or output, and call @code{(@var{proc} +port)} with the resulting port. Return the value returned by address@hidden + +For input, @var{filename} must exist. For output, if @var{filename} +already exists the behaviour is unspecified. In both cases if address@hidden cannot be opened an error is signalled. + +When @var{proc} returns, the port is closed. If @var{proc} does not +return (eg.@: if it throws an error), then the port may not be closed +automatically, though it will be garbage collected in the usual way if +not otherwise referenced. address@hidden deffn + address@hidden {Scheme Procedure} with-input-from-file filename thunk address@hidden {Scheme Procedure} with-output-to-file filename thunk address@hidden {Scheme Procedure} with-error-to-file filename thunk @rnindex with-input-from-file address@hidden {Scheme Procedure} with-input-from-file file thunk address@hidden must be a procedure of no arguments, and @var{file} must be -a string naming a file. The file must already exist. The file is opened -for input, an input port connected to it is made the default value -returned by @code{current-input-port}, and the @var{thunk} is called -with no arguments. When the @var{thunk} returns, the port is closed and -the previous default is restored. Returns the value yielded by address@hidden If an escape procedure is used to escape from the -continuation of these procedures, their behavior is implementation -dependent. address@hidden deffn - @rnindex with-output-to-file address@hidden {Scheme Procedure} with-output-to-file file thunk address@hidden must be a procedure of no arguments, and @var{file} must be -a string naming a file. The effect is unspecified if the file already -exists. The file is opened for output, an output port connected to it -is made the default value returned by @code{current-output-port}, and -the @var{thunk} is called with no arguments. When the @var{thunk} -returns, the port is closed and the previous default is restored. -Returns the value yielded by @var{thunk}. If an escape procedure is -used to escape from the continuation of these procedures, their behavior -is implementation dependent. address@hidden deffn - address@hidden {Scheme Procedure} with-error-to-file file thunk address@hidden must be a procedure of no arguments, and @var{file} must be -a string naming a file. The effect is unspecified if the file already -exists. The file is opened for output, an output port connected to it -is made the default value returned by @code{current-error-port}, and the address@hidden is called with no arguments. When the @var{thunk} returns, -the port is closed and the previous default is restored. Returns the -value yielded by @var{thunk}. If an escape procedure is used to escape -from the continuation of these procedures, their behavior is -implementation dependent. +Open @var{filename} and call @code{(@var{thunk})} with the port setup +as respectively the @code{current-input-port}, address@hidden, or @code{current-error-port}. Return the +value returned by @var{thunk}. + +For input, @var{filename} must exist. For output and error output, if address@hidden already exists the behaviour is unspecified. In all +cases if @var{filename} cannot be opened, an error is signalled. + +When @var{thunk} returns, the port is closed and the previous setting +of the respective current port is restored. If @var{thunk} does not +return (eg.@: if it throws an error), then what happens to the ports +is unspecified. @end deffn @deffn {Scheme Procedure} port-mode port