The Dynamic Loader Search Path

In SB-Prolog, it is not necessary for the user to load all the predicates necessary to execute a program. Instead, if an undefined predicate foo is encountered during execution, the system searches the user's directories in the order specified by the environment variable SIMPATH until it finds a directory containing a file foo whose name is that of the undefined predicate. It then dynamically loads and links the file foo (which is expected to be a byte code file defining the predicate foo), and continues with execution; if no such file can be found, an error message is given and execution fails. This feature makes it unnecessary for the user to have to explicitly link in all the predicates that might be necessary in a program: instead, only those files are loaded which are necessary to have the program execute. This can significantly reduce the memory requirements of programs.

The key to this dynamic search-and-load behaviour is the SIMPATH environment variable, which specifies the order in which directories are to be searched. It may be set by adding the following line to the user's .cshrc file:

setenv SIMPATH path
where path is a sequence of directory names separated by colons:
dir1:dir2: … : dirn
and diri are full path names to the respective directories. For example, executing the command
setenv SIMPATH .:$HOME/prolog/modlib:$HOME/prolog/lib
sets the search order for undefined predicates to the following: first, the directory in which the program is executing is searched; if the appropriate file is not found in this directory, the directories searched are, in order, /̃prolog/modlib and ˜/prolog/lib. If the appropriate file is not found in any of these directories, the system gives an error message and execution fails.

The beginning user is advised to include the system directories (listed in the next section) in his SIMPATH, in order to be able to access the system libraries (see below).