Input and output in IF/Prolog take place using device drivers which are managed on the basis of a driver model. A device driver is responsible for operations for a particular stream type, e.g. files, character strings or pipes. Prolog can manage different streams with the same set of generic built-in predicates. Prolog provides the following built-in devices:
In this context, Stream is the unique designation of an opened input or output channel, e.g. to a file, terminal or pipe. The designation is an opaque term created by the Prolog system. However, you may also use alias names which you assign to a stream.
This chapter describes both input/output in the top-level dialog and also elementary input/output in Prolog and the main built-in predicates concerned. It then explains how to work with files, pipes and sockets. How to add device drivers to the Prolog system is explained in section 10.3.