Environmental

op(priority, type, name)
op/3 (L) Treat name as an operator of the stated type and priority (see Section [*]). name may also be a list of names, in which all are to be treated as operators of the stated type and priority.

break
break/0 (L) Causes the current execution to be suspended at the next procedure call. Then the message [ Break (level 1) ] is displayed. The interpreter is then ready to accept input as though it was at the top level (except that at break level n > 0, the prompt is n: ?-). If another call of break is encountered, it moves up to level 2, and so on. To close the break and resume the execution which was suspended, type the END-OF-INPUT character. Execution will be resumed at the procedure call where it had been suspended. Alternatively, the suspended execution can be aborted by calling the evaluable predicate abort, which causes a return to the top level.

abort
abort/0 (B) Aborts the current execution, taking you back to top level.

save(F)
save/1 (B) The system saves the current state of the system into file F.

restore(F)
restore/1 (B) The system restores the saved state in file F to be the current state. One restriction imposed by the current system is that various system parameters (e.g. stack sizes, permanent space, heap space, etc.) of the saved state have to be the same as that of the current invocation. Thus, it is not possible to save a state from an invocation where 50000 words of permanent space had been allocated, and then restore the same state in an invocation with 100000 words of permanent space.

cputime(X)
cputime/1 (B) Unifies X with the time elapsed, in milliseconds, since the system was started up.

$getenv(Var,Val)
$getenv/2 (L) Val is unified with the value of the Unix environment variable Var. Fails is Var is undefined.

statistics
statistics/0 (B) Prints out the current allocations and amounts of space used for each of the four main areas: the permanent area, the local stack, the global stack and the trail stack. Does not work well unless the simulator has been called with the -s option (see Section [*]).

statistics(Keyword, List)
statistics/2 (L) Usually used with Keyword instantiated to a keyword, e.g. `runtime', and List unbound. It unifies List with a list of statistics determined by Keyword. The keys and values are summarized in Table [*]. Times are given in milliseconds and sizes are given in bytes.

Table: Run Time Statistics Predicates
Keyword List
runtime [cpu time used by Prolog, cpu time since
  last call to statistics/2]
memory [total virtual memory, 0]
core (same as for the keyword memory)
program [program space in use, program space free]
heap (same as for the keyword program)
global_stack [global stack in use, global stack free]
local_stack [local stack in use, local stack free]
trail [trail stack in use, trail stack free]
garbage_collection [0, 0]
stack_shifts [0, 0]
Note:
  1. For the keyword `memory' the second element of the returned list is always 0.
  2. For the keyword `trail', the second element of the returned list is the amount of trail stack free. This is similar to Sicstus Prolog (version 0.5), but different from Quintus Prolog (version 1.6).
  3. Currently, SB-Prolog does not have garbage collection or stack shifting, hence the list values returned for these are [0, 0].


nodynload(P, N)
nodynload/2 (L) Flags the predicate P with arity N as one that should not be attempted to be dynamically loaded if it is undefined. If a predicate so flagged is undefined when a call to it is encountered, the call fails quietly without trying to invoke the dynamic loader or giving an error message. P and N should be instantiated to an atom and an integer, respectively, at the time of call to nodynload/2.

symtype(T, N)
symtype/2 (B) Unifies N with the ``internal type'' of the principal functor of the term T, which must be instantiated at the time of the call. N is bound to 0 if T does not have an entry point defined (i.e. cannot be executed); to 1 if the principal functor of T is ``dynamic'', i.e. has asserted code; to 2 if the principal functor for T is a compiled predicate; and 3 if T denotes a buffer. Thus, for example, if the predicate p/2 is a compiled predicate which has been loaded into the system, the goal
| ?- symtype(p(_,_), X).
will succeed binding X to 2; on the other hand, the goal
| ?- assert(q(a,b,c)), symtype(q(_,_,_), X).
will succeed binding X to 1.

system(Call)
system/1 (B) Calls the operating system with the atom Call as argument. For example, the call
| ?- system('ls').
will produce a directory listing. Since system/1 is executed by forking off a shell process, it cannot be used, for example, to change the working directory of the simulator.

syscall(N, Args, Res)
syscall/3 (B) Executes the Unix system call number N with arguments Args, and returns the result in Res. N is an integer, and Args a Prolog list of the arguments to the system call. For example, to execute the system call creat(File,Mode), knowing that the syscall number for the Unix command creat(2) is 8, we execute the goal
| ?- syscall(8, [File, Mode], Des).
where Des is the file descriptor returned by creat. The syscall numbers for some Unix system calls are given in Table [*].

Table: Syscall Numbers for Some Unix Systems Calls
exit 1 fork 2
read 3 write 4
open 5 close 6
creat 8 link 9
unlink 10 chdir 12
chmod 15 lseek 19
access 33 kill 37
wait 84 socket 97
connect 98 accept 99
send 101 recv 102
bind 104 setsockopt 105
listen 106 recvmsg 113
sendmsg 114 getsockopt 118
recvfrom 125 sendto 133
socketpair 135 mkdir 136
rmdir 137 getsockname 150