REDUCE

10.1 Introduction

One category of input and output in LISP is ”symbolic” I/O. This allows a user to print or read possibly complex LISP objects with one or a few calls on standard functions. PSL also has powerful general-purpose I/O.

Input from multiple sources and output to multiple destinations can be done in PSL all at the same time. PSL provides I/O functions with explicit specification of sources and destinations for I/O. On the other hand for convenience it is often desirable to let the source or destination be implicit. PSL provides the full set of I/O operations through functions with an implicit source or destination.

The functions with and without an explicit channel designator argument are described together in this chapter. In each case calling the function with the implicit source or destination is the same as calling the version with explicit channel argument and supplying the value of the variable in* or out* as the channel.

The current input or output channel can be changed by setting or rebinding the variables in* or out*. Historically, the functions rds and wrs have been used for this and they are also available along with their special features.

10.1.1 Organization of this Chapter

We first discuss the syntax used for symbolic input and output. The syntax described applies to PSL programs, interactive typein, format of data in data files, and to output by PSL programs except when special formatting is used.

Functions for printing and reading follow. All (textual) input and output functions are discussed. Next is open, for setting up input and output with files, plus related functions. A great deal of user input/output programming can be done using just a subset of the functions described in these first sections.

PSL includes functions that load program modules and execute command files. They are essential to building of software systems even if the system itself does no I/O. Functions of this type are described next.

The section on I/O channels discusses some features available for switching the current output from channel to channel, and documents some fluid variables used in directing some of the system’s input and output.

Functions in the next section actually operate on objects such as lists and strings! Since I/O functions scan input and format output, and since it is possible to read from or print to a string, I/O functions can be useful for building strings and for scanning them. Some built-in functions are described.

The last two sections describe mechanisms that make possible some sophisticated uses of the PSL I/O system. One describes the mechanism in PSL that permits writing to a string or taking input from the text buffer of a text editor. The other discusses the tables used by the PSL scanner, which is modifiable.