Next: , Up: Lstreams   [Contents][Index]


20.1 Creating an Lstream

Lstreams come in different types, depending on what is being interfaced to. Although the primitive for creating new lstreams is Lstream_new(), generally you do not call this directly. Instead, you call some type-specific creation function, which creates the lstream and initializes it as appropriate for the particular type.

All lstream creation functions take a mode argument, specifying what mode the lstream should be opened as. This controls whether the lstream is for input and output, and optionally whether data should be blocked up in units of MULE characters. Note that some types of lstreams can only be opened for input; others only for output; and others can be opened either way. #### Richard Mlynarik thinks that there should be a strict separation between input and output streams, and he’s probably right.

mode is a string, one of

"r"

Open for reading.

"w"

Open for writing.

"rc"

Open for reading, but “read” never returns partial MULE characters.

"wc"

Open for writing, but never writes partial MULE characters.