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

This module provides partial compatibility with the XSB Prolog system

Source setup_dialect
Further dialect initialization. Called from expects_dialect/1.
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 xsb_set_prolog_flag(+Flag, +Value)
Map some XSB Prolog flags to their SWI-Prolog's equivalents.
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 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 sk_not(:P) is semidet
Sound negation with non-ground P. Equivalent to not_exists/1.
deprecated
- New code should use not_exists/1.
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.
Compatibility
- Due to the heuristic nature of garbage_collect_atoms/0, not all tables may be reclaimed immediately.
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 debug_ctl(+Option, +Value) is det
Control the XSB debugger. The current implementation merely defines the predicate. Much more can be mapped to SWI-Prolog primitives.
Source thread_shared(+Spec)
Declare a dynamic predicate as shared. This is the default for SWI-Prolog.
Source fmt_write(+Fmt, +Term) is det
Source fmt_write(+Stream, +Fmt, +Term) is det
C-style formatted write, where the arguments are formed by the arguments of Term. We map this to format/2,3.
bug
- We need to complete the translation of the fmt_write sequences to format/2,3 sequences.
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.
Compatibility
- 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.
Source abort(+Message:atomic)
Abort with a message

Re-exported predicates

The following predicates are exported from this file while their implementation is defined in imported modules or non-module files loaded by this module.

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 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 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 fmt_write(+Fmt, +Term) is det
Source fmt_write(+Stream, +Fmt, +Term) is det
C-style formatted write, where the arguments are formed by the arguments of Term. We map this to format/2,3.
bug
- We need to complete the translation of the fmt_write sequences to format/2,3 sequences.
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.
Compatibility
- 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.
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 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 timed_call(:Goal, :Options)
Emulation for XSB timed_call/2. Runs Goal as once/1 with timed interrupts. The interrupt goals are called as interrupts using the semantics of ignore/1: possible choice points are cut and failure is ignored. If the interrupt throws an exception this is propagated.

Options is a list of the terms below. At least one of the terms max/2 or repeating/2 must be present.

max(+MaxInterval, :MaxHandler)
Schedule a single interrupt calling MaxHandler at MaxInterval milliseconds from now.
repeating(+RepInterval, :RepHandler)
Schedule a repeating interrupt calling RepHandler each RepInterval milliseconds.
nesting
Nested calls to timed_call/2 are transformed into calls to once/1. Without nesting, a nested call raises a permission_error exception.
See also
- call_with_time_limit/2, alarm/4, thread_signal/2.
Compatibility
- This predicate is a generalization of the SWI-Prolog library(time) interface. It is left in the XSB emulation because it uses non-standard option syntax and the time is in milliseconds where all SWI-Prolog time handling uses seconds.