Program state
Author: Daniel Diaz
Keywords: GNU Prolog, manual, Prolog, compiler, constraints, finite domains

### 8.23 Program state

- consult/1, ’.’/2 - program consult
- load/1
- listing/1, listing/0

#### 8.23.1 consult/1, ’.’/2 - program consult

Templates

  consult(+atom_or_atom_list)
  ’.’(+atom, +atom_list)

Description

consult(Files) compiles and loads into memory each file of the list Files. Each file is compiled for byte-code using the GNU Prolog compiler (section 4.4) then loaded using load/1 (section 8.23.2). It is possible to specify user as a file name to directly enter the program from the terminal. Files can be also a single file name (i.e. an atom). Refer to the section concerning the consult of a Prolog program for more information (section 4.2.3).

The final file name of a file is computed using the predicates prolog_file_name/2 (section 8.26.4) and absolute_file_name/2 (section 8.26.1).

[ File | Files ], i.e. ’.’(File, Files) is equivalent to consult([ File | Files ]).

Since version 1.4.0, with the introduction of shebang support, consult/1 ignores the first line of a Prolog source file which directly begins with #. See (section 4.2.4) for more information about shebang support and PrologScript.

Errors

Files is a partial list or a list with an element E which is a variable |  | instantiation_error
Files is neither a partial list nor a list nor an atom |  | type_error(list, Files)
an element E of the Files list is neither a variable nor an atom |  | type_error(atom, E)
an element E of the Files list is an atom but not a valid pathname |  | domain_error(os_path, E)
an element E of the Files list is a valid pathname but does not correspond to an existing source |  | existence_error(source_sink, E)
an error occurs executing a directive |  | see call/1 errors (section 7.2.3)

Portability

GNU Prolog predicates.

#### 8.23.2 load/1

Templates

  load(+atom_or_atom_list)

Description

load(Files) loads into memory each file of the list Files. Each file must have been previously compiled for byte-code using the GNU Prolog compiler (section 4.4). Files can be also a single file name (i.e. an atom).

The final file name of a file is computed using the predicates absolute_file_name/2 (section 8.26.1). If no suffix is given ’.wbc’ is appended to the file name.

Errors

Files is a partial list or a list with an element E which is a variable |  | instantiation_error
Files is neither a partial list nor a list nor an atom |  | type_error(list, Files)
an element E of the Files list is neither a variable nor an atom |  | type_error(atom, E)
an element E of the Files list is an atom but not a valid pathname |  | domain_error(os_path, E)
an element E of the Files list is a valid pathname but does not correspond to an existing source |  | existence_error(source_sink, E)
an error occurs executing a directive |  | see call/1 errors (section 7.2.3)

Portability

GNU Prolog predicate.

#### 8.23.3 listing/1, listing/0

Templates

  listing(+predicate_indicator)
  listing(+atom)
  listing

Description

listing(Pred) lists the clauses of the consulted predicate whose predicate indicator is Pred. Pred can also be a single atom in which case all predicates whose name is Pred are listed (of any arity). This predicate uses portray_clause/2 (section 8.14.8) to output the clauses.

listing lists all clauses of all consulted predicates.

Errors

Pred is a variable |  | instantiation_error
Pred is neither a variable nor predicate indicator or an atom |  | type_error(predicate_indicator, Pred)

Portability

GNU Prolog predicate.

Copyright (C) 1999-2021 Daniel Diaz Verbatim copying and distribution of this entire article is permitted in any medium, provided this notice is preserved. More about the copyright