next up previous index
Next: Opening New Streams Up: Input and Output Previous: Streams in ECLiPSe

System Streams

  Apart from stream names defined by the user, ECLiPSe also contains 13 predefined logical system streams. At the beginning of a session they are assigned to the standard UNIX streams, but they can be changed by the user, except for those which must not be modified. The system streams are:  

input
Used by the input predicates that do not have the stream as an explicit argument, e.g. read/1.    

output
Used by the output predicates that do not have the stream as an explicit argument, e.g. write/1.    

error
Output for error messages and warnings and all messages about exceptional states.  

toplevel_input
The input for the top-level Prolog loop, it reads the user query and the semicolon or newline typed to indicate whether other solutions are required.    

toplevel_output
The messages from the top-level loop, e.g. the yes/no   answer, delayed goals, messages about loaded libraries.  

answer_output
Outputs the top-level loop answer bindings for the user query.  

debug_input
Input to the debugger.  

debug_output
Output from the debugger  

null
  A dummy stream, output to it is discarded, on input it always gives end of file. It can be used to ignore part of a program's output without having to remove the output predicates. Note that this stream is similar to the UNIX file '/dev/null' but works much faster. This stream cannot be redirected to any other physical stream.

Each of the physical input streams has its own prompt which is printed on the specified output stream whenever new input is required. The goal
set_prompt(InputStream, Prompt, OutputStream)
  sets the prompt for InputStream to be Prompt printed on the output stream OutputStream. The predicate get_prompt/3 can be used to query the prompt   of an input stream.

Apart from these system streams there are other logical stream identifiers provided by the system:

stdin
  The UNIX standard input stream when the ECLiPSe session is started.

stdout
  The UNIX standard output stream when the ECLiPSe session is started.

stderr
  The UNIX standard error output stream when the ECLiPSe session is started.

user
  This identifier is provided for compatibility with other Prolog systems and it is identical with stdin and stdout depending on the context where it is used. When it is not possible for the system to decide whether the input or output stream was meant by user, an exception is raised. This stream cannot be redirected to another physical stream.

The streams stdin, stdout and stderr are used to initialize all other system streams and also to reset them when the current system stream is closed. To allow greater flexibility of the system, these streams can be modified by the user.

When an attempt is made to close a system stream, the exception 196 is raised. The default handler for this exception resets all system streams connected with this physical streams to their defaults and then the physical stream is closed.

When set_stream(Logical_Stream, Stream) is used to redirect a system stream, Stream must have a mode compatible with that of Logical_Stream. That is, if Logical_Stream specifies a stream with read mode, Stream must have either read or update mode; if Logical_Stream has write mode, Stream must have either write, append or update mode; and if Logical_Stream has update mode, Stream must have update mode.



next up previous index
Next: Opening New Streams Up: Input and Output Previous: Streams in ECLiPSe



Micha Meier
Mon Mar 4 12:11:45 MET 1996