Did you know ... Search Documentation:
xsb.pl -- XSB Prolog compatibility layer
PublicShow source

This module provides partial compatibility with the XSB Prolog system

Source xsb_import(:Predicates, +From)
Make Predicates visible in From. As the XSB library structructure is rather different from SWI-Prolog's, this is a heuristic process.
Source add_lib_dir(+Directories) is det
Source add_lib_dir(+Root, +Directories) is det
Add members of the comma list Directories to library_directory/1. If Root is given, all members of Directories are interpreted relative to Root.
Source compile(File, Options)
The XSB version compiles a file into .xwam without loading it. We do not have that. Calling qcompile/1 seems the best start.
Source load_dyn(+FileName) is det
Source load_dyn(+FileName, +Direction) is det
Source load_dync(+FileName) is det
Source load_dync(+FileName, +Direction) is det
Proper implementation requires the Quintus all_dynamic option. SWI-Prolog never had that as clause/2 is allowed on static code, which is the main reason to want this.

The dync versions demand source in canonical format. In SWI-Prolog there is little reason to demand this.

Source set_global_compiler_options(+List) is det
Set the XSB global compiler options.
Source compiler_options(+Options) is det
Locally switch the compiler options
Source xsb_dynamic(Preds)
Apply dynamic to the original predicate. This deals with a sequence that seems common in XSB:
:- import p/1 from x.
:- dynamic p/1.

This also deals with :- dynamic Spec as Flags.

Source fail_if(:P)
Same as \+ (support XSB legacy code). As the XSB manual claims this is optimized we normally do goal expansion to \+/1.
Source not_exists(:P)
Source sk_not(:P)
XSB tabled negation. According to the XSB manual, sk_not/1 is an old name for not_exists/1. The predicates tnot/1 and not_exists/1 are not precisely the same. We ignore that for now.
Source gc_tables(-Remaining) is det
The table abolish predicates leave the actual destruction of the tables to the atom garbage collector to avoid deleting active tables. This predicate runs garbage_collect_atoms/0 and counts the remaining erased tables.
- Due to the heuristic nature of garbage_collect_atoms/0, not all tables may be reclaimed immediately.
Source is_most_general_term(@X) is semidet
Succeeds if X is compound term with all distinct variables as arguments, or if X is an atom. (It fails if X is a cons node.)
?- is_most_general_term(f(_,_,_,_)).
?- is_most_general_term(abc).
?- is_most_general_term(f(X,Y,Z,X)).
?- is_most_general_term(f(X,Y,Z,a)).
?- is_most_general_term([_|_]).
Source cputime(-Seconds) is det
True when Seconds is the used CPU time.
Source walltime(-Seconds) is det
True when Seconds is the wall time sice Prolog was started
Source path_sysop(+Op, ?Value) is semidet
Source path_sysop(+Op, ?Arg1, ?Arg2) is semidet
Unified interface to the operations on files. All these calls succeed iff the corresponding system call succeeds.
- The below implementation covers all operations from XSB 3.8. SWI file name operations are always on POSIX style file names. The implementation may have semantic differences.

Undocumented predicates

The following predicates are exported, but not or incorrectly documented.

Source sk_not(Arg1)
Source load_dync(Arg1, Arg2)
Source load_dyn(Arg1, Arg2)
Source load_dync(Arg1)
Source add_lib_dir(Arg1, Arg2)
Source path_sysop(Arg1, Arg2, Arg3)