Previous: Channels, Up: I/O system
Built-in to Scheme48 are ports made atop channels. These are what are
created by R5RS's standard file operations. The following names are
exported by the channel-ports
structure.
Standard R5RS file I/O operations. (These are also exported by the
scheme
structure.) Thecall-with-...put-file
operations open the specified type of port and apply receiver to it; after receiver returns normally (i.e. nothing is done if there is a throw out of receiver), they close the port and return the values that receiver returned.With-input-from-file
&with-output-to-file
do similarly, but, rather than applying thunk to the port, they dynamically bind the current input & output ports, respectively, to the newly opened ports.Call-with-input-file
,call-with-output-file
,with-input-from-file
, andwith-output-to-file
return the values that thunk returns.Open-input-file
&open-output-file
just open input & output ports; users of these operations must close them manually.
These create input & output ports atop the given channels and optional buffer sizes. The default buffer size is 4096 bytes.
Similarly, these create input & output ports atop the given channels and optional buffer sizes, but they allow for extra cleanup when the resulting ports are closed.