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
modification times.
load_files/[1,2] (and the predicates defined in terms
of 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 strings):
FileName exists, load it.
FileName.pl exists, but not FileName.qof, load FileName.pl
FileName.qof exists, but not FileName.pl, load FileName.qof
FileName.pl and FileName.qof exist, load the one
that was most recently modified.
For example,
| ?- [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 /usr/prolog
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)).