Quintus Prolog Manual
The Quintus Prolog Library directory (part of the installation directory described in {manual(a-1)}) includes six subdirectories which contain files written in Prolog and C which supplement the Quintus Prol kernel:
The predicate library_directory/1 has predefined clauses for the library and tools directories. These depend on the file_search_path/2 definition of qplib. You can see these clauses by typing "listing." or "listing(library_directory)." after starting up Prolog. This definition of library_directory/1 means that you can refer, from within Prolog, to any file in any of these areas using the form library(File). For example either (A) or (B) would load the file lists.qof from the 'library' directory.
| ?- [library(lists)]. (A)
| ?- load_files(library(lists)). (B)
Library packages are typically loaded by doing (C) if the package is not a module-file or if it is a module and you want all the exported predicates.
| ?- ensure_loaded(library(add_portray)). (C)
See the descriptions of ensure_loaded/1 and use_module/[1,2,3]. You will notice that the library name 'add_portray' includes an underscore. Some file systems do not permit underscores in file names. The 'library(_)' wrapper exists, in part, to decouple library names from file names, and Quintus Prolog will remove the underscores if necessary. Use absolute_file_name/[2,3] to find out the actual filename of any library package. In addition to the loadable QOF files, source files (.pl or .c) are provided for each package.
The predicates described here have been tested and are believed to work as documented. If you want something slightly different from one of these predicates, it is strongly recommended that you do not change the existing definition. Instead, write a new predicate using the existing definition as a model. There are several reasons for not changing the definition of a predicate in the library:
All library packages include code comments, often extensive, which serve as documentation. Accessing these comments and other information available in the library directory is discussed in {manual(k-1-3-1)}. In addition, many packages are more fully documented:
protalk/1.0/doc/manual.doc
protalk/1.0/doc/manual.ps
The rest are abstracted in {manual(k-12)}. For these the information in the following section is particularly useful.
If you know the name of the library package in question, simply look at the source code in qplib3.3. Apart from code comments, there is information about predicates in two files which summarize the contents of the directory. They are called Contents and Index. If you do not know the name of the package the Index file will be helpful. If you know the name of the package, you can use the Contents file to gain further information about it. The Index file contains one line for each exported predicate in the library. The predicates are listed in standard order, ignoring module names. A typical entry looks like this:
list_to_binary/4 flatten ./flatten.pl
This means that there is a predicate called list_to_binary/4 in the library, that it lives in a module called 'flatten', and that the file which contains it is 'flatten.pl' in the same directory as the Index. If you have set up an "environment variable" QL holding the name of the Quintus library directory, you could ask "what predicates are there to deal with files?" by issuing the UNIX command
% egrep files $QL/Index
The Contents file is organized by library files rather than by predicates. A typical entry in this file is a block of lines like this:
basics + documented in manual
basics % the basic list processing predicates
basics - ./basics.pl
basics : member/2
basics : memberchk/2
basics : nonmember/2
The first line means that library(basics) is one of the library packages which is fully documented in this manual. The second line is a short description of the contents. The third line says which file contains library(basics); in this case it is 'basics.pl' in the same directory as Contents. The remaining lines list the predicates exported by library(basics). You could obtain this information by issuing the UNIX command
% egrep '^basics' $QL/Contents
These files are provided as a convenience, and do not have the same authority as the printed manual.
Many of the examples in this manual show lists of character codes being written as quoted strings. This actually happens if you load the library package library(print_chars). That package extends the predicate portray/1 (using library(add_portray)) so that print/1, the top-level, and the debugger will write lists of character codes as follows:
| ?- X = [0'a,0'b,0'c].
X = [97,98,99]
| ?- ensure_loaded(library(print_chars)).
| ?- X = [0'a,0'b,0'c].
X = "abc"
A new system of representing the modes of arguments has been adapted in Release 3, is described in {manual(l)}. The library, including IPC, is still documented under the old system of mode annotations: Each predicate definition is headed by a goal template such as
setof(?X,+Goal,-Set)
Here X and the others are meta-variables which name the arguments so that we don't have to keep saying "its first argument" and so on. The characters which precede the meta-variables will seem familiar if you know the mode declarations of DEC-10 Prolog; their significance is as follows:
Note that it is not an error to call a predicate with a '-' argument already instantiated. The value supplied will simply be unified with the result returned, and if that unification fails, the predicate fails.