next up previous
Next: Analysing and Constructing Up: Built-In Predicates Previous: Primitive Character Input

Term Reading and Writing

display( +Term)

  Write Term on the current output stream using standard parenthesised prefix notation (i.e. ignoring operator declarations). Display is normally used to examine the internal representation for terms holding operators.
display( +Stream, +Term)

  Display Term on Stream.
displayq( +Term)

  Write Term on the current output stream using standard parenthesised prefix notation (i.e. ignoring operator declarations). Atoms that need quotes are quoted. Terms written with this predicate can always be read back, regardless of current operator declarations.
displayq( +Stream, +Term)

  Display Term on Stream. Equivalent to Quintus write_canonical/2.
write( +Term)

  Write Term to the current output, using brackets and operators where appropriate.
write( +Stream, +Term)

  Write Term to Stream.
writeq( +Term)

  Write Term to the current output, using brackets and operators where appropriate. Atoms that need quotes are quoted. Terms written with this predicate can be read back with read/1 provided the currently active operator declarations are identical.
writeq( +Stream, +Term)

  Write Term to Stream, inserting quotes.
print( +Term)

  Prints Term on the current output stream similar to write/1, but for each (sub)term of Term first the dynamic predicate portray/1 is called. If this predicate succeeds print assumes the (sub)term has been written. This allows for user defined term writing.
print( +Stream, +Term)

  Print Term to Stream.
portray( +Term)

  A dynamic predicate, which can be defined by the user to change the behaviour of print/1 on (sub)terms. For each subterm encountered that is not a variable print/1 first calls portray/1 using the term as argument. For lists only the list as a whole is given to portray/1. If portray succeeds print/1 assumes the term has been written.
read( -Term)

  Read the next Prolog term from the current input stream and unify it with Term. On a syntax error read/1 displays an error message, attempts to skip the erroneous term and fails. On reaching end-of-file Term is unified with the atom end_of_file.
read( +Stream, -Term)

  Read Term from Stream.
read_clause( -Term)

  Equivalent to read/1, but warns the user for variables only occurring once in a term (singleton variables) which do not start with an underscore if style_check(singleton) is active (default). Used to read Prolog source files (see consult/1).
read_clause( +Stream, -Term)

  Read a clause from Stream.
read_variables( -Term, -Bindings)

  Similar to read/1, but Bindings is unified with a list of `' tuples, thus providing access to the actual variable names.
read_variables( +Stream, -Term, -Bindings)

  Read, returning term and bindings from Stream.
read_history( +Show, +Help, +Special, +Prompt, -Term, -Bindings)

  Similar to read_variables/2, but allows for history substitutions. history_read/6 is used by the top level to read the user's actions. Show is the command the user should type to show the saved events. Help is the command to get an overview of the capabilities. Special is a list of commands that are not saved in the history. Prompt is the first prompt given. Continuation prompts for more lines are determined by prompt/2. A %w in the prompt is substituted by the event number. See section gif for available substitutions.

SWI-Prolog calls history_read/6 as follows:

read_history(h, '!h', [trace], '%w ?- ', Goal, Bindings)

history_depth( -Int)

  Dynamic predicate, normally not defined. The user can define this predicate to set the history depth. It should unify the argument with a positive integer. When not defined 15 is used as the default.
prompt( -Old, +New)

  Set prompt associated with read/1 and its derivates. Old is first unified with the current prompt. On success the prompt will be set to New if this is an atom. Otherwise an error message is displayed. A prompt is printed if one of the read predicates is called and the cursor is at the left margin. It is also printed whenever a newline is given and the term has not been terminated. Prompts are only printed when the current input stream is user.



next up previous
Next: Analysing and Constructing Up: Built-In Predicates Previous: Primitive Character Input



Passani Luca
Tue Nov 14 08:58:33 MET 1995