3.6 How do I make things happen at compile time?
A file being compiled may contain queries. These are goals
preceded by either the symbol “?-” or the symbol “:-”.
As soon as a query or command is encountered in the compilation of a file,
the ECLiPSe system will try to satisfy it.
Thus by inserting goals in this fashion, things can be made to happen at
In particular, a file can contain a directive to the system
to compile another file, and so large programs can be split between files,
while still only requiring a single simple command to compile them.
When this happens, ECLiPSe interprets the pathnames of the nested
compiled files relative to the directory of the parent compiled file;
if, for example, the user calls
and the file src/pl/prog.pl contains a query
[eclipse 1]: compile('src/pl/prog').
then the system searches for the files part1.pl and part2.pl in the
directory src/pl and not in the current directory.
Usually larger ECLiPSe programs have one main file which contains
only commands to compile all the subfiles.
In ECLiPSe it is possible to compile this main file from any directory.
(Note that if your program is large enough to warrant breaking into multiple
files (let alone multiple directories), it is probably worth turning the
constituent components into modules — see chapter 7.)
:- [part1, part2].