docs
This commit is contained in:
parent
3966bf2ee1
commit
828c2c9f6e
3
.gitignore
vendored
3
.gitignore
vendored
@ -137,4 +137,5 @@ debug
|
||||
Release
|
||||
Build
|
||||
xcode
|
||||
Threads
|
||||
Threads
|
||||
mxe
|
107
pl/absf.md
107
pl/absf.md
@ -1,107 +0,0 @@
|
||||
|
||||
@addtogroup absolute_file_name
|
||||
|
||||
@pred absolute_file_name(+File:atom, +Options:list, +Path:atom) is nondet
|
||||
@pred absolute_file_name(-File:atom, +Path:atom, +Options:list) is nondet
|
||||
|
||||
_Options_ is a list of options to guide the conversion:
|
||||
|
||||
- extensions(+ _ListOfExtensions_)
|
||||
|
||||
List of file-name suffixes to add to try adding to the file. The
|
||||
Default is the empty suffix, `''`. For each extension,
|
||||
absolute_file_name/3 will first add the extension and then verify
|
||||
the conditions imposed by the other options. If the condition
|
||||
fails, the next extension of the list is tried. Extensions may
|
||||
be specified both with dot, as `.ext`, or without, as plain
|
||||
`ext`.
|
||||
|
||||
- relative_to(+ _FileOrDir_ )
|
||||
|
||||
Resolve the path relative to the given directory or directory the
|
||||
holding the given file. Without this option, paths are resolved
|
||||
relative to the working directory (see working_directory/2) or,
|
||||
if _Spec_ is atomic and absolute_file_name/3 is executed
|
||||
in a directive, it uses the current source-file as reference.
|
||||
|
||||
- access(+ _Mode_ )
|
||||
|
||||
Imposes the condition access_file( _File_ , _Mode_ ). _Mode_ is one of `read`, `write`, `append`, `exist` or
|
||||
`none` (default).
|
||||
|
||||
See also access_file/2.
|
||||
|
||||
- file_type(+ _Type_ )
|
||||
|
||||
Defines suffixes matching one of several pre-specified type of files. Default mapping is as follows:
|
||||
|
||||
1. `txt` implies `[ '' ]`,
|
||||
|
||||
2. `prolog` implies `['.yap', '.pl', '.prolog', '']`,
|
||||
|
||||
3. `executable` implies `['.so', ',dylib', '.dll']` depending on the Operating system,
|
||||
|
||||
4. `qly` implies `['.qly', '']`,
|
||||
|
||||
5. `directory` implies `['']`,
|
||||
|
||||
6. The file-type `source` is an alias for `prolog` designed to support compatibility with SICStus Prolog. See also prolog_file_type/2.
|
||||
|
||||
Notice that this predicate only
|
||||
returns non-directories, unless the option `file_type(directory)` is
|
||||
specified, or unless `access(none)`.
|
||||
|
||||
- file_errors(`fail`/`error`)
|
||||
|
||||
If `error` (default), throw `existence_error` exception
|
||||
if the file cannot be found. If `fail`, stay silent.
|
||||
|
||||
- solutions(`first`/`all`)
|
||||
|
||||
If `first` (default), commit to the first solution. Otherwise
|
||||
absolute_file_name will enumerate all solutions via backtracking.
|
||||
|
||||
- expand(`true`/`false`)
|
||||
|
||||
If `true` (default is `false`) and _Spec_ is atomic, call
|
||||
expand_file_name/2 followed by member/2 on _Spec_ before
|
||||
proceeding. This is originally a SWI-Prolog extension, but
|
||||
whereas SWI-Prolog implements its own conventions, YAP uses the
|
||||
shell's `glob` primitive.
|
||||
|
||||
- glob(`Pattern`)
|
||||
|
||||
If _Pattern_ is atomic, add the pattern as a suffix to the current expansion, and call
|
||||
expand_file_name/2 followed by member/2 on the result. This is originally a SICStus Prolog exception.
|
||||
|
||||
Both `glob` and `expand` rely on the same underlying
|
||||
mechanism. YAP gives preference to `glob`.
|
||||
|
||||
- verbose_file_search(`true`/`false`)
|
||||
|
||||
If `true` (default is `false`) output messages during
|
||||
search. This is often helpful when debugging. Corresponds to the
|
||||
SWI-Prolog flag `verbose_file_search` (also available in YAP).
|
||||
|
||||
|
||||
Compatibility considerations to common argument-order in ISO as well
|
||||
as SICStus absolute_file_name/3 forced us to be flexible here.
|
||||
If the last argument is a list and the second not, the arguments are
|
||||
swapped, making the call
|
||||
~~~~~~~~~~~prolog
|
||||
absolute_file_name(+ _Spec_ , - _Path_ ,+ _Options_ )
|
||||
~~~~~~~~~~~
|
||||
valid as well.
|
||||
|
||||
|
||||
@pred user:library_directory(?Directory:atom) is nondet, dynamic
|
||||
|
||||
Dynamic, multi-file predicate that succeeds when _Directory_ is a
|
||||
current library directory name. Asserted in the user module.
|
||||
|
||||
Library directories are the places where files specified in the form
|
||||
`library( _File_ )` are searched by the predicates consult/1,
|
||||
reconsult/1, use_module/1, ensure_loaded/1, and load_files/2.
|
||||
|
||||
This directory is initialized by a rule that calls the system predicate
|
||||
system_library/1.
|
461
pl/absf.yap
461
pl/absf.yap
@ -8,10 +8,14 @@
|
||||
* *
|
||||
*************************************************************************/
|
||||
|
||||
%% @file absf.yap
|
||||
%% @author L.Damas, V.S.Costa
|
||||
/**
|
||||
|
||||
%% @{
|
||||
|
||||
|
||||
@file absf.yap
|
||||
@author L.Damas, V.S.Costa
|
||||
|
||||
*/
|
||||
|
||||
:- system_module( absf, [absolute_file_name/2,
|
||||
absolute_file_name/3,
|
||||
@ -21,186 +25,124 @@
|
||||
remove_from_path/1], ['$full_filename'/3,
|
||||
'$system_library_directories'/2]).
|
||||
|
||||
/** @defgroup absf File Name Resolution
|
||||
/**
|
||||
|
||||
@ingroup builtins
|
||||
@defgroup AbsoluteFileName File Name Resolution
|
||||
@ingroup builtins
|
||||
|
||||
Support for file name resolution through absolute_file_name/3 and
|
||||
Support for file name resolution through absolute_file_name/3 and
|
||||
friends. These utility built-ins describe a list of directories that
|
||||
are used by load_files/2 to search. They include pre-compiled paths
|
||||
plus user-defined directories, directories based on environment
|
||||
variables and registry information to search for files.
|
||||
|
||||
**/
|
||||
@{
|
||||
|
||||
*/
|
||||
|
||||
:- use_system_module( '$_boot', ['$system_catch'/4]).
|
||||
|
||||
:- use_system_module( '$_errors', ['$do_error'/2]).
|
||||
|
||||
:- use_system_module( '$_lists', [member/2]).
|
||||
|
||||
:- multifile user:library_directory/1.
|
||||
|
||||
:- dynamic user:library_directory/1.
|
||||
%% user:library_directory( ?Dir )
|
||||
% Specifies the set of directories where
|
||||
% one can find Prolog libraries.
|
||||
%
|
||||
% 1. honor YAPSHAREDIR
|
||||
user:library_directory( Dir ) :-
|
||||
getenv( 'YAPSHAREDIR', Dir0),
|
||||
absolute_file_name( Dir0, [file_type(directory), expand(true),file_errors(fail)], Dir ).
|
||||
%% 2. honor user-library
|
||||
user:library_directory( Dir ) :-
|
||||
absolute_file_name( '~/share/Yap', [file_type(directory), expand(true),file_errors(fail)], Dir ).
|
||||
%% 3. honor current directory
|
||||
user:library_directory( Dir ) :-
|
||||
absolute_file_name( '.', [file_type(directory), expand(true),file_errors(fail)], Dir ).
|
||||
%% 4. honor default location.
|
||||
user:library_directory( Dir ) :-
|
||||
system_library( Dir ).
|
||||
|
||||
/**
|
||||
@pred user:commons_directory(? _Directory_:atom) is nondet, dynamic
|
||||
|
||||
State the location of the Commons Prolog Initiative.
|
||||
@pred absolute_file_name( -File:atom, +Path:atom, +Options:list) is nondet
|
||||
|
||||
This directory is initialized as a rule that calls the system predicate
|
||||
library_directories/2.
|
||||
_Options_ is a list of options to guide the conversion:
|
||||
|
||||
- extensions(+ _ListOfExtensions_)
|
||||
|
||||
List of file-name suffixes to add to try adding to the file. The
|
||||
Default is the empty suffix, `''`. For each extension,
|
||||
absolute_file_name/3 will first add the extension and then verify
|
||||
the conditions imposed by the other options. If the condition
|
||||
fails, the next extension of the list is tried. Extensions may
|
||||
be specified both with dot, as `.ext`, or without, as plain
|
||||
`ext`.
|
||||
|
||||
- relative_to(+ _FileOrDir_ )
|
||||
|
||||
Resolve the path relative to the given directory or directory the
|
||||
holding the given file. Without this option, paths are resolved
|
||||
relative to the working directory (see working_directory/2) or,
|
||||
if _Spec_ is atomic and absolute_file_name/3 is executed
|
||||
in a directive, it uses the current source-file as reference.
|
||||
|
||||
- access(+ _Mode_ )
|
||||
|
||||
Imposes the condition access_file( _File_ , _Mode_ ). _Mode_ is one of `read`, `write`, `append`, `exist` or
|
||||
`none` (default).
|
||||
|
||||
See also access_file/2.
|
||||
|
||||
- file_type(+ _Type_ )
|
||||
|
||||
Defines suffixes matching one of several pre-specified type of files. Default mapping is as follows:
|
||||
|
||||
1. `txt` implies `[ '' ]`,
|
||||
|
||||
2. `prolog` implies `['.yap', '.pl', '.prolog', '']`,
|
||||
|
||||
3. `executable` implies `['.so', ',dylib', '.dll']` depending on the Operating system,
|
||||
|
||||
4. `qly` implies `['.qly', '']`,
|
||||
|
||||
5. `directory` implies `['']`,
|
||||
|
||||
6. The file-type `source` is an alias for `prolog` designed to support compatibility with SICStus Prolog. See also prolog_file_type/2.
|
||||
|
||||
Notice that this predicate only
|
||||
returns non-directories, unless the option `file_type(directory)` is
|
||||
specified, or unless `access(none)`.
|
||||
|
||||
- file_errors(`fail`/`error`)
|
||||
|
||||
If `error` (default), throw `existence_error` exception
|
||||
if the file cannot be found. If `fail`, stay silent.
|
||||
|
||||
- solutions(`first`/`all`)
|
||||
|
||||
If `first` (default), commit to the first solution. Otherwise
|
||||
absolute_file_name will enumerate all solutions via backtracking.
|
||||
|
||||
- expand(`true`/`false`)
|
||||
|
||||
If `true` (default is `false`) and _Spec_ is atomic, call
|
||||
expand_file_name/2 followed by member/2 on _Spec_ before
|
||||
proceeding. This is originally a SWI-Prolog extension, but
|
||||
whereas SWI-Prolog implements its own conventions, YAP uses the
|
||||
shell's `glob` primitive.
|
||||
|
||||
Notice that in `glob` mode YAP will fail if it cannot find a matching file, as `glob`
|
||||
implicitely tests for existence when checking for patterns.
|
||||
|
||||
- glob(`Pattern`)
|
||||
|
||||
If _Pattern_ is atomic, add the pattern as a suffix to the current expansion, and call
|
||||
expand_file_name/2 followed by member/2 on the result. This is originally a SICStus Prolog exception.
|
||||
|
||||
Both `glob` and `expand` rely on the same underlying
|
||||
mechanism. YAP gives preference to `glob`.
|
||||
|
||||
- verbose_file_search(`true`/`false`)
|
||||
|
||||
If `true` (default is `false`) output messages during
|
||||
search. This is often helpful when debugging. Corresponds to the
|
||||
SWI-Prolog flag `verbose_file_search` (also available in YAP).
|
||||
|
||||
|
||||
Compatibility considerations to common argument-order in ISO as well
|
||||
as SICStus absolute_file_name/3 forced us to be flexible here.
|
||||
If the last argument is a list and the second not, the arguments are
|
||||
swapped, thus the call
|
||||
~~~~~~~~~~~~
|
||||
?- absolute_file_name( 'pl/absf.yap', [], Path)
|
||||
~~~~~~~~~~~~
|
||||
is valid as well.
|
||||
*/
|
||||
|
||||
:- multifile user:commons_directory/1.
|
||||
|
||||
:- dynamic user:commons_directory/1.
|
||||
|
||||
|
||||
user:commons_directory( Path ):-
|
||||
system_commons( Path ).
|
||||
|
||||
/**
|
||||
@pred user:foreign_directory(? _Directory_:atom) is nondet, dynamic
|
||||
|
||||
State the location of the Foreign Prolog Initiative.
|
||||
|
||||
This directory is initialized as a rule that calls the system predicate
|
||||
library_directories/2.
|
||||
*/
|
||||
|
||||
:- multifile user:foreign_directory/1.
|
||||
|
||||
:- dynamic user:foreign_directory/1.
|
||||
|
||||
user:foreign_directory( Path ):-
|
||||
system_foreign( Path ).
|
||||
|
||||
/**
|
||||
@pred user:prolog_file_type(?Suffix:atom, ?Handler:atom) is nondet, dynamic
|
||||
|
||||
This multifile/dynamic predicate relates a file extension _Suffix_
|
||||
to a language or file type _Handler_. By
|
||||
default, it supports the extensions yap, pl, and prolog for prolog files and
|
||||
uses one of dll, so, or dylib for shared objects. Initial definition is:
|
||||
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~prolog
|
||||
prolog_file_type(yap, prolog).
|
||||
prolog_file_type(pl, prolog).
|
||||
prolog_file_type(prolog, prolog).
|
||||
prolog_file_type(qly, prolog).
|
||||
prolog_file_type(qly, qly).
|
||||
prolog_file_type(A, prolog) :-
|
||||
current_prolog_flag(associate, A),
|
||||
A \== prolog,
|
||||
A \==pl,
|
||||
A \== yap.
|
||||
prolog_file_type(A, executable) :-
|
||||
current_prolog_flag(shared_object_extension, A).
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
*/
|
||||
|
||||
:- multifile user:prolog_file_type/2.
|
||||
|
||||
:- dynamic user:prolog_file_type/2.
|
||||
|
||||
user:prolog_file_type(yap, prolog).
|
||||
user:prolog_file_type(pl, prolog).
|
||||
user:prolog_file_type(prolog, prolog).
|
||||
user:prolog_file_type(A, prolog) :-
|
||||
current_prolog_flag(associate, A),
|
||||
A \== prolog,
|
||||
A \== pl,
|
||||
A \== yap.
|
||||
user:prolog_file_type(qly, qly).
|
||||
user:prolog_file_type(A, executable) :-
|
||||
current_prolog_flag(shared_object_extension, A).
|
||||
|
||||
|
||||
/**
|
||||
@pred user:file_search_path(+Name:atom, -Directory:atom) is nondet
|
||||
|
||||
Allows writing file names as compound terms. The _Name_ and
|
||||
_DIRECTORY_ must be atoms. The predicate may generate multiple
|
||||
solutions. The predicate is originally defined as follows:
|
||||
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~prolog
|
||||
file_search_path(library, Dir) :-
|
||||
library_directory(Dir).
|
||||
file_search_path(commons, Dir) :-
|
||||
commons_directory(Dir).
|
||||
file_search_path(swi, Home) :-
|
||||
current_prolog_flag(home, Home).
|
||||
file_search_path(yap, Home) :-
|
||||
current_prolog_flag(home, Home).
|
||||
file_search_path,(system, Dir) :-
|
||||
prolog_flag(host_type, Dir).
|
||||
file_search_path(foreign, Dir) :-
|
||||
foreign_directory(Dir).
|
||||
file_search_path(path, C) :-
|
||||
( getenv('PATH', A),
|
||||
( current_prolog_flag(windows, true)
|
||||
-> atomic_list_concat(B, ;, A)
|
||||
; atomic_list_concat(B, :, A)
|
||||
),
|
||||
lists:member(C, B)
|
||||
).
|
||||
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Thus, `compile(library(A))` will search for a file using
|
||||
library_directory/1 to obtain the prefix,
|
||||
whereas 'compile(system(A))` would look at the `host_type` flag.
|
||||
|
||||
@}
|
||||
|
||||
*/
|
||||
|
||||
:- multifile user:file_search_path/2.
|
||||
|
||||
:- dynamic user:file_search_path/2.
|
||||
|
||||
user:file_search_path(library, Dir) :-
|
||||
user:library_directory(Dir).
|
||||
user:file_search_path(commons, Dir) :-
|
||||
user:commons_directory(Dir).
|
||||
user:file_search_path(swi, Home) :-
|
||||
current_prolog_flag(home, Home).
|
||||
user:file_search_path(yap, Home) :-
|
||||
current_prolog_flag(home, Home).
|
||||
user:file_search_path(system, Dir) :-
|
||||
prolog_flag(host_type, Dir).
|
||||
user:file_search_path(foreign, Dir) :-
|
||||
working_directory(Dir,Dir).
|
||||
user:file_search_path(foreign, yap('lib/Yap')).
|
||||
user:file_search_path(path, C) :-
|
||||
( getenv('PATH', A),
|
||||
( current_prolog_flag(windows, true)
|
||||
-> atomic_list_concat(B, ;, A)
|
||||
; atomic_list_concat(B, :, A)
|
||||
),
|
||||
lists:member(C, B)
|
||||
).
|
||||
|
||||
%%@}
|
||||
|
||||
absolute_file_name(File,TrueFileName,Opts) :-
|
||||
( var(TrueFileName) ->
|
||||
true ;
|
||||
@ -361,7 +303,9 @@ absolute_file_name(File0,File) :-
|
||||
atom_codes(DA,[D]),
|
||||
atom_concat( [File1, DA, Glob], File2 ),
|
||||
expand_file_name(File2, ExpFiles),
|
||||
'$enumerate_glob'(File1, ExpFiles, ExpFile)
|
||||
% glob is not very much into failing
|
||||
[File2] \== ExpFiles,
|
||||
'$enumerate_glob'(File2, ExpFiles, ExpFile)
|
||||
;
|
||||
Expand == true
|
||||
->
|
||||
@ -570,6 +514,8 @@ add_to_path(New,Pos) :-
|
||||
|
||||
/** @pred remove_from_path(+Directory:atom) is det,deprecated
|
||||
|
||||
@}
|
||||
|
||||
*/
|
||||
remove_from_path(New) :- '$check_path'(New,Path),
|
||||
recorded('$path',Path,R), erase(R).
|
||||
@ -579,3 +525,186 @@ remove_from_path(New) :- '$check_path'(New,Path),
|
||||
'$check_path'([Ch],[Ch]) :- '$dir_separator'(Ch), !.
|
||||
'$check_path'([Ch],[Ch,A]) :- !, integer(Ch), '$dir_separator'(A).
|
||||
'$check_path'([N|S],[N|SN]) :- integer(N), '$check_path'(S,SN).
|
||||
|
||||
/**
|
||||
@defgroup pathconf Configuration of the Prolog file search path
|
||||
@ingroup AbsoluteFileName
|
||||
|
||||
Prolog systems search follow a complex search on order to track down files.
|
||||
|
||||
@{
|
||||
**/
|
||||
|
||||
/**
|
||||
@pred user:library_directory(?Directory:atom) is nondet, dynamic
|
||||
|
||||
Dynamic, multi-file predicate that succeeds when _Directory_ is a
|
||||
current library directory name. Asserted in the user module.
|
||||
|
||||
Library directories are the places where files specified in the form
|
||||
`library( _File_ )` are searched by the predicates consult/1,
|
||||
reconsult/1, use_module/1, ensure_loaded/1, and load_files/2.
|
||||
|
||||
This directory is initialized by a rule that calls the system predicate
|
||||
system_library/1.
|
||||
*/
|
||||
:- multifile user:library_directory/1.
|
||||
|
||||
:- dynamic user:library_directory/1.
|
||||
%% Specifies the set of directories where
|
||||
% one can find Prolog libraries.
|
||||
%
|
||||
% 1. honor YAPSHAREDIR
|
||||
user:library_directory( Dir ) :-
|
||||
getenv( 'YAPSHAREDIR', Dir0),
|
||||
absolute_file_name( Dir0, [file_type(directory), expand(true),file_errors(fail)], Dir ).
|
||||
%% 2. honor user-library
|
||||
user:library_directory( Dir ) :-
|
||||
absolute_file_name( '~/share/Yap', [file_type(directory), expand(true),file_errors(fail)], Dir ).
|
||||
%% 3. honor current directory
|
||||
user:library_directory( Dir ) :-
|
||||
absolute_file_name( '.', [file_type(directory), expand(true),file_errors(fail)], Dir ).
|
||||
%% 4. honor default location.
|
||||
user:library_directory( Dir ) :-
|
||||
system_library( Dir ).
|
||||
|
||||
/**
|
||||
@pred user:commons_directory(? _Directory_:atom) is nondet, dynamic
|
||||
|
||||
State the location of the Commons Prolog Initiative.
|
||||
|
||||
This directory is initialized as a rule that calls the system predicate
|
||||
library_directories/2.
|
||||
*/
|
||||
|
||||
:- multifile user:commons_directory/1.
|
||||
|
||||
:- dynamic user:commons_directory/1.
|
||||
|
||||
|
||||
user:commons_directory( Path ):-
|
||||
system_commons( Path ).
|
||||
|
||||
/**
|
||||
@pred user:foreign_directory(? _Directory_:atom) is nondet, dynamic
|
||||
|
||||
State the location of the Foreign Prolog Initiative.
|
||||
|
||||
This directory is initialized as a rule that calls the system predicate
|
||||
library_directories/2.
|
||||
*/
|
||||
|
||||
:- multifile user:foreign_directory/1.
|
||||
|
||||
:- dynamic user:foreign_directory/1.
|
||||
|
||||
user:foreign_directory( Path ):-
|
||||
system_foreign( Path ).
|
||||
|
||||
/**
|
||||
@pred user:prolog_file_type(?Suffix:atom, ?Handler:atom) is nondet, dynamic
|
||||
|
||||
This multifile/dynamic predicate relates a file extension _Suffix_
|
||||
to a language or file type _Handler_. By
|
||||
default, it supports the extensions yap, pl, and prolog for prolog files and
|
||||
uses one of dll, so, or dylib for shared objects. Initial definition is:
|
||||
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~prolog
|
||||
prolog_file_type(yap, prolog).
|
||||
prolog_file_type(pl, prolog).
|
||||
prolog_file_type(prolog, prolog).
|
||||
prolog_file_type(qly, prolog).
|
||||
prolog_file_type(qly, qly).
|
||||
prolog_file_type(A, prolog) :-
|
||||
current_prolog_flag(associate, A),
|
||||
A \== prolog,
|
||||
A \==pl,
|
||||
A \== yap.
|
||||
prolog_file_type(A, executable) :-
|
||||
current_prolog_flag(shared_object_extension, A).
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
*/
|
||||
|
||||
:- multifile user:prolog_file_type/2.
|
||||
|
||||
:- dynamic user:prolog_file_type/2.
|
||||
|
||||
user:prolog_file_type(yap, prolog).
|
||||
user:prolog_file_type(pl, prolog).
|
||||
user:prolog_file_type(prolog, prolog).
|
||||
user:prolog_file_type(A, prolog) :-
|
||||
current_prolog_flag(associate, A),
|
||||
A \== prolog,
|
||||
A \== pl,
|
||||
A \== yap.
|
||||
user:prolog_file_type(qly, qly).
|
||||
user:prolog_file_type(A, executable) :-
|
||||
current_prolog_flag(shared_object_extension, A).
|
||||
|
||||
|
||||
/**
|
||||
@pred user:file_search_path(+Name:atom, -Directory:atom) is nondet
|
||||
|
||||
Allows writing file names as compound terms. The _Name_ and
|
||||
_DIRECTORY_ must be atoms. The predicate may generate multiple
|
||||
solutions. The predicate is originally defined as follows:
|
||||
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~prolog
|
||||
file_search_path(library, Dir) :-
|
||||
library_directory(Dir).
|
||||
file_search_path(commons, Dir) :-
|
||||
commons_directory(Dir).
|
||||
file_search_path(swi, Home) :-
|
||||
current_prolog_flag(home, Home).
|
||||
file_search_path(yap, Home) :-
|
||||
current_prolog_flag(home, Home).
|
||||
file_search_path,(system, Dir) :-
|
||||
prolog_flag(host_type, Dir).
|
||||
file_search_path(foreign, Dir) :-
|
||||
foreign_directory(Dir).
|
||||
file_search_path(path, C) :-
|
||||
( getenv('PATH', A),
|
||||
( current_prolog_flag(windows, true)
|
||||
-> atomic_list_concat(B, ;, A)
|
||||
; atomic_list_concat(B, :, A)
|
||||
),
|
||||
lists:member(C, B)
|
||||
).
|
||||
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Thus, `compile(library(A))` will search for a file using
|
||||
library_directory/1 to obtain the prefix,
|
||||
whereas 'compile(system(A))` would look at the `host_type` flag.
|
||||
|
||||
*/
|
||||
|
||||
:- multifile user:file_search_path/2.
|
||||
|
||||
:- dynamic user:file_search_path/2.
|
||||
|
||||
user:file_search_path(library, Dir) :-
|
||||
user:library_directory(Dir).
|
||||
user:file_search_path(commons, Dir) :-
|
||||
user:commons_directory(Dir).
|
||||
user:file_search_path(swi, Home) :-
|
||||
current_prolog_flag(home, Home).
|
||||
user:file_search_path(yap, Home) :-
|
||||
current_prolog_flag(home, Home).
|
||||
user:file_search_path(system, Dir) :-
|
||||
prolog_flag(host_type, Dir).
|
||||
user:file_search_path(foreign, Dir) :-
|
||||
working_directory(Dir,Dir).
|
||||
user:file_search_path(foreign, yap('lib/Yap')).
|
||||
user:file_search_path(path, C) :-
|
||||
( getenv('PATH', A),
|
||||
( current_prolog_flag(windows, true)
|
||||
-> atomic_list_concat(B, ;, A)
|
||||
; atomic_list_concat(B, :, A)
|
||||
),
|
||||
lists:member(C, B)
|
||||
).
|
||||
|
||||
|
||||
%% @}
|
@ -15,7 +15,9 @@
|
||||
* *
|
||||
*************************************************************************/
|
||||
|
||||
% the default mode is on
|
||||
% the default mode is on
|
||||
|
||||
%% @file arith.yap
|
||||
|
||||
:- system_module( '$_arith', [compile_expressions/0,
|
||||
expand_exprs/2,
|
||||
@ -112,7 +114,7 @@ q(A):-
|
||||
A is 22.
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
w*/
|
||||
*/
|
||||
do_not_compile_expressions :- set_value('$c_arith',[]).
|
||||
|
||||
'$c_built_in'(IN, M, H, OUT) :-
|
||||
|
@ -15,8 +15,6 @@
|
||||
* *
|
||||
*************************************************************************/
|
||||
|
||||
%% @{
|
||||
|
||||
/**
|
||||
|
||||
@defgroup YAPControl Control Predicates
|
||||
@ -24,6 +22,8 @@
|
||||
|
||||
*/
|
||||
|
||||
%% @{
|
||||
|
||||
|
||||
|
||||
/** @pred :_P_ ; :_Q_ is iso
|
||||
|
@ -97,7 +97,7 @@ files and to set-up the Prolog environment. We discuss
|
||||
|
||||
/**
|
||||
|
||||
@pred load_files(+ _Files_, + _Options_)
|
||||
@pred load_files(+_Files_, +_Options_)
|
||||
|
||||
Implementation of the consult/1 family. Execution is controlled by the
|
||||
following flags:
|
||||
|
@ -81,10 +81,10 @@
|
||||
/**
|
||||
|
||||
|
||||
@{
|
||||
|
||||
@addtogroup YAPControl
|
||||
|
||||
%% @{
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
10
pl/error.yap
10
pl/error.yap
@ -23,8 +23,9 @@
|
||||
is_of_type/2 % +Type, +Term
|
||||
]).
|
||||
|
||||
/** @defgroup error Error generating support
|
||||
@ingroup builtin
|
||||
/**
|
||||
@defgroup error Error generating support
|
||||
@ingroup YAPError
|
||||
|
||||
This SWI module provides predicates to simplify error generation and
|
||||
checking. Adapted to use YAP built-ins.
|
||||
@ -36,6 +37,9 @@ predicates are simple wrappers around throw/1 to simplify throwing the
|
||||
most common ISO error terms.
|
||||
|
||||
YAP reuses the code with some extensions, and supports interfacing to some C-builtins.
|
||||
|
||||
@{
|
||||
|
||||
*/
|
||||
|
||||
:- multifile
|
||||
@ -255,3 +259,5 @@ must_be_instantiated(X) :-
|
||||
|
||||
must_be_instantiated(X, Comment) :-
|
||||
( var(X) -> instantiation_error(X, Comment) ; true).
|
||||
|
||||
%% @}
|
||||
|
240
pl/errors.yap
240
pl/errors.yap
@ -11,210 +11,84 @@
|
||||
* File: errors.yap *
|
||||
* comments: error messages for YAP *
|
||||
* *
|
||||
* Last rev: $Date: 2008-07-22 23:34:50 $,$Author: vsc $ *
|
||||
* $Log: not supported by cvs2svn $
|
||||
* Revision 1.89 2008/06/12 10:55:52 vsc
|
||||
* fix syntax error messages
|
||||
*
|
||||
* Revision 1.88 2008/04/04 10:02:44 vsc
|
||||
* implement thread_cancel using signals
|
||||
* use duplicate_term instead of copy_term in throw: throw may lose
|
||||
* reference to term.
|
||||
*
|
||||
* Revision 1.87 2008/03/17 12:08:28 vsc
|
||||
* avoid silly message
|
||||
*
|
||||
* Revision 1.86 2008/02/23 01:32:31 vsc
|
||||
* fix chr bootstrap.
|
||||
*
|
||||
* Revision 1.85 2008/02/22 15:08:37 vsc
|
||||
* Big update to support more SICStus/SWI like message handling
|
||||
* fix YAPSHAREDIR
|
||||
* fix yap.tex (Bernd)
|
||||
*
|
||||
* Revision 1.84 2008/01/23 17:57:55 vsc
|
||||
* valgrind it!
|
||||
* enable atom garbage collection.
|
||||
*
|
||||
* Revision 1.83 2007/11/26 23:43:10 vsc
|
||||
* fixes to support threads and assert correctly, even if inefficiently.
|
||||
*
|
||||
* Revision 1.82 2007/09/27 23:02:00 vsc
|
||||
* encoding/1
|
||||
*
|
||||
* Revision 1.81 2007/09/27 15:25:34 vsc
|
||||
* upgrade JPL
|
||||
*
|
||||
* Revision 1.80 2007/01/24 14:20:04 vsc
|
||||
* Fix typos across code
|
||||
* Change debugger to backtrack more alike byrd model
|
||||
* Fix typo in debugger option f
|
||||
*
|
||||
* Revision 1.79 2006/12/13 16:10:26 vsc
|
||||
* several debugger and CLP(BN) improvements.
|
||||
*
|
||||
* Revision 1.78 2006/05/22 16:12:01 tiagosoares
|
||||
* MYDDAS: MYDDAS version boot message
|
||||
*
|
||||
* Revision 1.77 2006/04/10 19:24:52 vsc
|
||||
* fix syntax error message handling
|
||||
* improve redblack trees and use it to reimplement association lists and
|
||||
* to have better implementation of several graph algorithms.
|
||||
*
|
||||
* Revision 1.76 2006/04/05 00:16:55 vsc
|
||||
* Lots of fixes (check logfile for details
|
||||
*
|
||||
* Revision 1.75 2006/02/24 14:26:37 vsc
|
||||
* fix informational_messages
|
||||
*
|
||||
* Revision 1.74 2006/01/26 19:20:00 vsc
|
||||
* syntax error was giving the offset
|
||||
*
|
||||
* Revision 1.73 2006/01/20 04:35:28 vsc
|
||||
*
|
||||
* fix error message
|
||||
*
|
||||
* Revision 1.72 2005/11/23 13:24:00 vsc
|
||||
* cleanups in OS interface predicates.
|
||||
*
|
||||
* Revision 1.71 2005/11/10 01:27:12 vsc
|
||||
* fix debugger message for EOF input
|
||||
* fix fix to setof
|
||||
* fix profiler spewing out hidden atoms.
|
||||
*
|
||||
* Revision 1.70 2005/11/03 18:27:10 vsc
|
||||
* fix quote
|
||||
*
|
||||
* Revision 1.69 2005/11/01 18:54:06 vsc
|
||||
* small fixes
|
||||
*
|
||||
* Revision 1.68 2005/10/29 01:28:37 vsc
|
||||
* make undefined more ISO compatible.
|
||||
*
|
||||
* Revision 1.67 2005/10/28 17:38:50 vsc
|
||||
* sveral updates
|
||||
*
|
||||
* Revision 1.66 2005/10/18 17:04:43 vsc
|
||||
* 5.1:
|
||||
* - improvements to GC
|
||||
* 2 generations
|
||||
* generic speedups
|
||||
* - new scheme for attvars
|
||||
* - hProlog like interface also supported
|
||||
* - SWI compatibility layer
|
||||
* - extra predicates
|
||||
* - global variables
|
||||
* - moved to Prolog module
|
||||
* - CLP(R) by Leslie De Koninck, Tom Schrijvers, Cristian Holzbaur, Bart
|
||||
* Demoen and Jan Wielemacker
|
||||
* - load_files/2
|
||||
*
|
||||
* from 5.0.1
|
||||
*
|
||||
* - WIN32 missing include files (untested)
|
||||
* - -L trouble (my thanks to Takeyuchi Shiramoto-san)!
|
||||
* - debugging of backtrable user-C preds would core dump.
|
||||
* - redeclaring a C-predicate as Prolog core dumps.
|
||||
* - badly protected YapInterface.h.
|
||||
* - break/0 was failing at exit.
|
||||
* - YAP_cut_fail and YAP_cut_succeed were different from manual.
|
||||
* - tracing through data-bases could core dump.
|
||||
* - cut could break on very large computations.
|
||||
* - first pass at BigNum issues (reported by Roberto).
|
||||
* - debugger could get go awol after fail port.
|
||||
* - weird message on wrong debugger option.
|
||||
*
|
||||
* Revision 1.65 2005/05/25 21:43:33 vsc
|
||||
* fix compiler bug in 1 << X, found by Nuno Fonseca.
|
||||
* compiler internal errors get their own message.
|
||||
*
|
||||
* Revision 1.64 2005/05/25 18:18:02 vsc
|
||||
* fix error handling
|
||||
* configure should not allow max-memory and use-malloc at same time
|
||||
* some extensions for jpl
|
||||
*
|
||||
* Revision 1.63 2005/04/20 20:06:26 vsc
|
||||
* try to improve error handling and warnings from within consults.
|
||||
*
|
||||
* Revision 1.62 2005/04/07 17:55:05 ricroc
|
||||
* Adding tabling support for mixed strategy evaluation (batched and local scheduling)
|
||||
* UPDATE: compilation flags -DTABLING_BATCHED_SCHEDULING and -DTABLING_LOCAL_SCHEDULING removed. To support tabling use -DTABLING in the Makefile or --enable-tabling in configure.
|
||||
* NEW: yap_flag(tabling_mode,MODE) changes the tabling execution mode of all tabled predicates to MODE (batched, local or default).
|
||||
* NEW: tabling_mode(PRED,MODE) changes the default tabling execution mode of predicate PRED to MODE (batched or local).
|
||||
*
|
||||
* Revision 1.61 2005/02/21 16:50:21 vsc
|
||||
* amd64 fixes
|
||||
* library fixes
|
||||
*
|
||||
* Revision 1.60 2005/01/28 23:14:41 vsc
|
||||
* move to Yap-4.5.7
|
||||
* Fix clause size
|
||||
*
|
||||
* Revision 1.59 2005/01/13 05:47:27 vsc
|
||||
* lgamma broke arithmetic optimisation
|
||||
* integer_y has type y
|
||||
* pass original source to checker (and maybe even use option in parser)
|
||||
* use warning mechanism for checker messages.
|
||||
*
|
||||
* Revision 1.58 2004/11/19 21:32:53 vsc
|
||||
* change abort so that it won't be caught by handlers.
|
||||
*
|
||||
* Revision 1.57 2004/10/27 15:56:34 vsc
|
||||
* bug fixes on memory overflows and on clauses :- fail being ignored by clause.
|
||||
*
|
||||
* Revision 1.56 2004/10/04 18:56:20 vsc
|
||||
* fixes for thread support
|
||||
* fix indexing bug (serious)
|
||||
*
|
||||
* Revision 1.55 2004/09/17 19:34:53 vsc
|
||||
* simplify frozen/2
|
||||
*
|
||||
* Revision 1.54 2004/07/22 21:32:22 vsc
|
||||
* debugger fixes
|
||||
* initial support for JPL
|
||||
* bad calls to garbage collector and gc
|
||||
* debugger fixes
|
||||
*
|
||||
* Revision 1.53 2004/06/23 17:24:20 vsc
|
||||
* New comment-based message style
|
||||
* Fix thread support (at least don't deadlock with oneself)
|
||||
* small fixes for coroutining predicates
|
||||
* force Yap to recover space in arrays of dbrefs
|
||||
* use private predicates in debugger.
|
||||
*
|
||||
* Revision 1.52 2004/06/18 15:41:19 vsc
|
||||
* fix extraneous line in yes/no messages
|
||||
*
|
||||
* Revision 1.51 2004/06/09 03:32:03 vsc
|
||||
* fix bugs
|
||||
*
|
||||
* Revision 1.50 2004/04/27 16:21:25 vsc
|
||||
* stupid bug
|
||||
* *
|
||||
* *
|
||||
*************************************************************************/
|
||||
|
||||
|
||||
/** @defgroup YAPError Error Handling
|
||||
|
||||
@ingroup YAPControl
|
||||
|
||||
The error handler is called when there is an execution error or a
|
||||
warning needs to be displayed. The handlers include a number of hooks
|
||||
to allow user-control.
|
||||
|
||||
Errors are terms of the form:
|
||||
|
||||
- error( domain_error( Domain, Culprit )`
|
||||
- error( evaluation_error( Expression, Culprit )`
|
||||
- error( existence_error( Object, Culprit )`
|
||||
- error( instantiation_error )`
|
||||
- error( permission_error( Error, Permission, Culprit)`
|
||||
- error( representation_error( Domain, Culprit )`
|
||||
- error( resource_error( Resource, Culprit )`
|
||||
- error( syntax_error( Error )`
|
||||
- error( system_error( Domain, Culprit )`
|
||||
- error( type_error( Type, Culprit )`
|
||||
- error( uninstantiation_error( Culprit )`
|
||||
|
||||
@{
|
||||
|
||||
*/
|
||||
|
||||
:- system_module( '$_errors', [message_to_string/2,
|
||||
print_message/2], ['$Error'/1,
|
||||
'$do_error'/2]).
|
||||
:- system_module( '$_errors', [system_error/2], ['$Error'/1,
|
||||
'$do_error'/2,
|
||||
system_error/3,
|
||||
system_error/2]).
|
||||
|
||||
:- use_system_module( '$messages', [file_location/2,
|
||||
generate_message/3,
|
||||
translate_message/3]).
|
||||
|
||||
|
||||
/**
|
||||
* @pred system_error( +Error, +Cause)
|
||||
*
|
||||
* Generate a system error _Error_, informing the possible cause _Cause_.
|
||||
*
|
||||
*/
|
||||
system_error(Type,Goal) :-
|
||||
'$do_error'(Type,Goal).
|
||||
|
||||
|
||||
'$do_error'(Type,Goal) :-
|
||||
% format('~w~n', [Type]),
|
||||
ancestor_location(Call, Caller),
|
||||
throw(error(Type, [
|
||||
[g|g(Goal)],
|
||||
[p|Call],
|
||||
[e|Caller]])).
|
||||
|
||||
/**
|
||||
* @pred system_error( +Error, +Cause, +Culprit)
|
||||
*
|
||||
* Generate a system error _Error_, informing the source goal _Cause_ and a possible _Culprit_.
|
||||
*
|
||||
*
|
||||
* ~~~~~~~~~~
|
||||
* ~~~~~~~~~~
|
||||
*
|
||||
*
|
||||
*/
|
||||
system_error(Type,Goal,Culprit) :-
|
||||
% format('~w~n', [Type]),
|
||||
ancestor_location(Call, Caller),
|
||||
throw(error(Type, [
|
||||
[i|Culprit],
|
||||
[g|g(Goal)],
|
||||
[p|Call],
|
||||
[e|Caller]])).
|
||||
|
||||
|
||||
'$do_error'(Type,Goal) :-
|
||||
@ -263,3 +137,5 @@ to allow user-control.
|
||||
print_message(error,error(Msg, Where)), !.
|
||||
'$process_error'(Throw, _) :-
|
||||
print_message(error,error(unhandled_exception,Throw)).
|
||||
|
||||
%% @}
|
@ -66,6 +66,7 @@ right hand side of a grammar rule
|
||||
|
||||
Grammar related built-in predicates:
|
||||
|
||||
@{
|
||||
|
||||
*/
|
||||
|
||||
|
@ -16,6 +16,9 @@
|
||||
* *
|
||||
*************************************************************************/
|
||||
|
||||
|
||||
%% @file pl/hacks.yap
|
||||
|
||||
:- module('$hacks',
|
||||
[display_stack_info/4,
|
||||
display_stack_info/6,
|
||||
|
@ -24,8 +24,12 @@
|
||||
|
||||
:- use_system_module( '$_modules', ['$do_import'/3]).
|
||||
|
||||
/** @defgroup LoadForeign Access to Foreign Language Programs
|
||||
@ingroup builtins
|
||||
/**
|
||||
|
||||
@defgroup LoadForeign Access to Foreign Language Programs
|
||||
@ingroup fli
|
||||
|
||||
@{
|
||||
|
||||
*/
|
||||
|
||||
@ -49,7 +53,6 @@ if defined, or in the default library.
|
||||
|
||||
YAP also supports the SWI-Prolog interface to loading foreign code:
|
||||
|
||||
|
||||
*/
|
||||
load_foreign_files(Objs,Libs,Entry) :-
|
||||
source_module(M),
|
||||
@ -205,5 +208,5 @@ call_shared_object_function( Handle, Function) :-
|
||||
'$call_shared_object_function'( Handle, Function),
|
||||
prolog_load_context(module, M),
|
||||
ignore( recordzifnot( '$foreign', M:'$swi_foreign'( Handle, Function ), _) ).
|
||||
%%! @}
|
||||
%% @}
|
||||
|
||||
|
@ -28,8 +28,6 @@
|
||||
|
||||
/**
|
||||
|
||||
@{
|
||||
|
||||
@defgroup Messages Message Handling
|
||||
@ingroup YAPControl
|
||||
|
||||
@ -67,6 +65,7 @@ messages that do not produce output but that can be intercepted by hooks.
|
||||
The next table shows the main predicates and hooks associated to message
|
||||
handling in YAP:
|
||||
|
||||
@{
|
||||
|
||||
*/
|
||||
|
||||
@ -269,6 +268,9 @@ main_message(error(representation_error), _Source) -->
|
||||
main_message(error(type_error(Type,Who), _What), _Source) -->
|
||||
[ '~*|!!! ~q should be of type ~a' - [8,Who,Type]],
|
||||
[ nl ].
|
||||
main_message(error(system_error(Who), _What), _Source) -->
|
||||
[ '~*|!!! ~q error' - [8,Who]],
|
||||
[ nl ].
|
||||
main_message(error(uninstantiation_error(T),_), _Source) -->
|
||||
[ '~*|!!! found ~q, expected unbound variable ' - [8,T], nl ].
|
||||
|
||||
@ -528,7 +530,8 @@ domain_error(Domain, Opt) -->
|
||||
|
||||
extra_info( error(_,Extra), _ ) -->
|
||||
{lists:memberchk([i|Msg], Extra)}, !,
|
||||
[' ~w~nx.' - [Msg] ].
|
||||
['~*|user provided data is: ~q' - [10,Msg]],
|
||||
[nl].
|
||||
extra_info( _, _ ) -->
|
||||
[].
|
||||
|
||||
@ -587,7 +590,7 @@ list_of_preds([P|L]) -->
|
||||
list_of_preds(L).
|
||||
|
||||
syntax_error_term(between(_I,_J,_L),LTaL) -->
|
||||
% ['found at line ~d to line ~d' - [_I,_L], nl ],
|
||||
['error found at line ~d to line ~d' - [_I,_L], nl ],
|
||||
syntax_error_tokens(LTaL).
|
||||
|
||||
syntax_error_tokens([]) --> [].
|
||||
|
@ -22,8 +22,6 @@
|
||||
], [] ).
|
||||
:- use_system_module( '$_errors', ['$do_error'/2]).
|
||||
|
||||
%% @{
|
||||
|
||||
/**
|
||||
@defgroup YAPOS Access to Operating System Functionality
|
||||
@ingroup builtins
|
||||
@ -31,6 +29,8 @@
|
||||
The following built-in predicates allow access to underlying
|
||||
Operating System functionality.
|
||||
|
||||
%% @{
|
||||
|
||||
*/
|
||||
|
||||
/** @pred cd
|
||||
|
@ -15,6 +15,12 @@
|
||||
* *
|
||||
*************************************************************************/
|
||||
|
||||
%% @file pl/profile.yap
|
||||
|
||||
:- system_module( '$_profile', [profile_data/3,
|
||||
profile_reset/0,
|
||||
showprofres/0,
|
||||
showprofres/1], []).
|
||||
|
||||
/** @defgroup The_Count_Profiler The Count Profiler
|
||||
@ingroup Profiling
|
||||
@ -28,8 +34,8 @@ backtracking. It provides exact information:
|
||||
are maintained. This may change in the future.
|
||||
+ As an example, the following user-level program gives a list of
|
||||
the most often called procedures in a program. The procedure
|
||||
`list_profile` shows all procedures, irrespective of module, and
|
||||
the procedure `list_profile/1` shows the procedures being used in
|
||||
list_profile/0 shows all procedures, irrespective of module, and
|
||||
the procedure list_profile/1 shows the procedures being used in
|
||||
a specific module.
|
||||
|
||||
~~~~~
|
||||
@ -63,11 +69,6 @@ These are the current predicates to access and clear profiling data:
|
||||
*/
|
||||
|
||||
|
||||
:- system_module( '$_profile', [profile_data/3,
|
||||
profile_reset/0,
|
||||
showprofres/0,
|
||||
showprofres/1], []).
|
||||
|
||||
:- use_system_module( '$_errors', ['$do_error'/2]).
|
||||
|
||||
|
||||
@ -76,7 +77,7 @@ These are the current predicates to access and clear profiling data:
|
||||
% describing a predicate; used e.g. on the tick profiler defined below
|
||||
:- multifile(user:prolog_predicate_name/2).
|
||||
|
||||
/** @pred profile_data(? _Na/Ar_, ? _Parameter_, - _Data_)
|
||||
/** @pred profile_data( ?Na/Ar, ?Parameter, -Data_)
|
||||
|
||||
|
||||
Give current profile data on _Parameter_ for a predicate described
|
||||
|
@ -14,6 +14,9 @@
|
||||
* comments: fast save/restore *
|
||||
* *
|
||||
*************************************************************************/
|
||||
|
||||
%% @file qly.yap
|
||||
|
||||
:- system_module( '$_qly', [qload_module/1,
|
||||
qsave_file/1,
|
||||
qsave_module/1,
|
||||
@ -55,6 +58,8 @@ saved.
|
||||
YAP always tries to find saved states from the current directory
|
||||
first. If it cannot it will use the environment variable [YAPLIBDIR](@ref YAPLIBDIR), if
|
||||
defined, or search the default library directory.
|
||||
|
||||
@{
|
||||
*/
|
||||
|
||||
/** @pred save_program(+ _F_)
|
||||
@ -778,3 +783,5 @@ qload_file( F0 ) :-
|
||||
fail.
|
||||
'$process_directives'( _FilePl ) :-
|
||||
abolish(user:'$file_property'/1).
|
||||
|
||||
%% @}
|
32
pl/setof.yap
32
pl/setof.yap
@ -25,9 +25,16 @@
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
:- system_module( '$_setof', [(^)/2,
|
||||
all/3,
|
||||
bagof/3,
|
||||
findall/3,
|
||||
findall/4,
|
||||
setof/3], []).
|
||||
|
||||
/**
|
||||
|
||||
@{
|
||||
@defgroup Sets Collecting Solutions to a Goal
|
||||
@ingroup builtins
|
||||
|
||||
@ -40,41 +47,36 @@ predicates instead of writing his own routines. findall/3 gives you
|
||||
the fastest, but crudest solution. The other built-in predicates
|
||||
post-process the result of the query in several different ways:
|
||||
|
||||
@{
|
||||
|
||||
|
||||
|
||||
*/
|
||||
|
||||
:- system_module( '$_setof', [(^)/2,
|
||||
all/3,
|
||||
bagof/3,
|
||||
findall/3,
|
||||
findall/4,
|
||||
setof/3], []).
|
||||
|
||||
:- use_system_module( '$_boot', ['$catch'/3]).
|
||||
|
||||
:- use_system_module( '$_errors', ['$do_error'/2]).
|
||||
|
||||
% The "existential quantifier" symbol is only significant to bagof
|
||||
% and setof, which it stops binding the quantified variable.
|
||||
% op(200, xfy, ^) is defined during bootstrap.
|
||||
|
||||
% this is used by the all predicate
|
||||
|
||||
:- op(50,xfx,same).
|
||||
|
||||
|
||||
%% @pred ^/2
|
||||
%
|
||||
% The "existential quantifier" symbol is only significant to bagof
|
||||
% and setof, which it stops binding the quantified variable.
|
||||
% op(200, xfy, ^) is defined during bootstrap.
|
||||
|
||||
_^Goal :-
|
||||
'$execute'(Goal).
|
||||
|
||||
|
||||
% findall/3 is a simplified version of bagof which has an implicit
|
||||
% existential quantifier on every variable.
|
||||
|
||||
|
||||
/** @pred findall( _T_,+ _G_,- _L_) is iso
|
||||
|
||||
findall/3 is a simplified version of bagof which has an implicit
|
||||
existential quantifier on every variable.
|
||||
|
||||
Unifies _L_ with a list that contains all the instantiations of the
|
||||
term _T_ satisfying the goal _G_.
|
||||
|
Reference in New Issue
Block a user