Previous Up Next
7.23 Program state

7.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 3.4) then loaded using load/1 (section 7.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 3.2.3).

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

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

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 6.2.3)

Portability

GNU Prolog predicates.

7.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 3.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 7.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 6.2.3)

Portability

GNU Prolog predicate.

7.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 7.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-2002 Daniel Diaz.

Chapters 9 and 10 : Copyright (C) 2002-2003 INRIA, Rémy Haemmerlé.

Verbatim copying and distribution of this entire article is permitted in any medium, provided this notice is preserved.

More about the copyright
Previous Up Next