The optional ImperativeIO functor can be used to implement (derive) an imperative-style stream IO facility in terms of a lazy functional stream IO facility. In the imperative style, input and output operations do not return a new stream each time but side-effect their arguments. Most functions can raise the Io exception for various reasons, including illegal or inconsistent parameters, IO failures, and attempts to do IO on closed streams.
The ImperativeIO functor is not often needed, as the required BinIO and TextIO structures supply imperative-style IO for most situations. It plays a useful role when the programmer needs to construct IO facilities with element types other than char or Word8.word, or ones based on user-specified IO primitives.
ImperativeIO( ... ) : IMPERATIVE_IO
structure StreamIO : STREAM_IO
structure Vector : MONO_VECTOR
structure Array : MONO_ARRAY
sharing StreamIO.elem = Vector.elem = Array.elem
sharing StreamIO.vector = Vector.vector = Array.vector
StreamIOand do a little extra bookkeeping.
STREAM_IO, IMPERATIVE_IO, StreamIO
Last Modified April 15, 1996
Comments to John Reppy.
Copyright © 1997 Bell Labs, Lucent Technologies