next up previous contents
Next: The Debugging Issue Up: Interlude: Practical Matters Previous: Avoiding Various Kinds

Input/Output Facilities

We now mention, in passing, some of the I/O facilities built into Prolog. We have already met a way of inputting multiple clauses via consult/1 (and reconsult/1). We have already met predicates that produce output --- write/1 and nl/0--- in chapter 4. Much more information can be found in chapter 10.10.

For now, we will not show how to output to a file ---see chapter 10.10 for the details. In passing, we mention that a single Prolog term can be read in using read/1. Input using this predicate must be terminated by the standard `.' followed by white space.

Here are some low level I/O predicates:

 
get0(X)			unifies  X with next non blank printable character

(in ASCII code) from current input stream

get(X) unifies X with next character (in ASCII) from

current input stream

put(X) puts a character on to the current output stream.

X must be bound to a legal ASCII code

Note that they do not have a declarative reading. They fit poorly into the theoretical structure underlying Prolog ---but other languages suffer from this problem ( e.g. ML).



Paul Brna
Mon May 24 20:14:48 BST 1999