All input and output functions are implemented in terms of operations on ”channels”. A channel is just a small integer 1 1The range of channel numbers is from 0 to MaxChannels, where MaxChannels is a system-dependent constant, currently 31, defined in the module io-decls which has 3 functions and some other information associated with it. The three functions are:
The read function must also be concerned with the handling of ends of ”files” (actually, ends of channels) and ends of lines. It should return the ASCII code for an end of file character (system dependent) when reaching the end of a channel. It should return the ASCII code for a line feed character to indicate an end of line (or ”newline”). This may require that the ASCII code for carriage return be ignored when read, not returned.
The other information associated with a channel includes the current position in the output line (used by posn), the maximum line length allowed (used by linelength and the printing functions), the single character input backup buffer (used by the token scanner), and other system-dependent information.
Ordinarily, the user need not be aware of the existence of this mechanism. However, because of its generality, it is possible to implement operations other than just reading from and writing to files using it. In particular, the LISP functions explode and compress are performed by writing to a list and reading from a list, respectively (on channels 3 and 4 respectively).
If Open is called with AccessType eq to SPECIAL and the global variables specialreadfunction*, specialwritefunction*, and specialclosefunction* are bound to ids, then a free channel is returned and its associated functions are set to the values of these variables. Other non system-dependent status is set to default conditions, which can later be overridden. The functions readonlychannel and writeonlychannel are available as error handlers. The parameter Filename is used only if an error occurs.
The following globals are used by the functions in this section.