Some of the predicates that take file specification arguments not only
can search for a file among the directories defined by
file_search_path/2 facts (if a path alias is used), but also can
help the user in finding the correct file by adding appropriate
extensions and/or looking for the most recent file by comparing
load_files/[1,2] (and the predicates defined in terms
load_files/2), uses the following algorithm to find the
most appropriate file to load:
library(strings)are given, look in the first library directory, with FileName set to
exists, load it.
.plexists, but not
.qofexists, but not
.qofexist, load the one that was most recently modified.
| ?- [user]. | :- multifile file_search_path/2. | :- dynamic file_search_path/2. | file_search_path(home, '/usr'). | file_search_path(home, '/usr/prolog'). | end_of_file. % (or <^D>) % user compiled in module user, 0.034 sec 284 bytes yes
In this case the directory
/usr is searched first and
second. Therefore, if the file
foo.pl exists in both of these
directories, the following query will compile
foo.pl in the directory
/usr (on the condition that
foo.qof does not exist).
| ?- compile(library(foo)).