Templates
Description
consult(Files, Options) 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.3). 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).
Consult options: Options is a list of consult options. If this list contains contradictory options, the rightmost option is the one which applies. Possible options are:
Implicit include file: due to separate compilation consult/1-2 creates an include file which is passed to the Prolog to WAM compiler (section 4.4.3). This is done by calling write_default_include_file/1 (section 8.23.2).
Shebang support: 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.
consult(Files) is equivalent to consult(Files, []).
[ 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 | |
| Options 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) | |
| Options is neither a partial list nor a list | type_error(list, Options) | |
| 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 Options list is neither a variable nor a valid write-option | domain_error(consult_option, 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.
Templates
Description
write_default_include_file(FileName) writes onto FileName relevant information influencing the parsing of a term (section 8.14) or its expansion (section 8.17). This allows a sub-process written in Prolog to first process this file in order to later process any Prolog term as would be done by the parent process. The following elements are saved in the FileName surrounded by compiler_mode/1 directives:
Errors
| FileName is a variable | instantiation_error | |
| FileName is neither a variable nor an atom | type_error(atom, FileName) | |
| an operating system error occurs and the value of the os_error Prolog flag is error (section 8.22.1) | system_error(atom explaining the error) | |
Portability
GNU Prolog predicate.
Templates
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.
Templates
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-2025 Daniel Diaz Verbatim copying and distribution of this entire article is permitted in any medium, provided this notice is preserved. More about the copyright