[ Predicate Database and Compiler | The ECLiPSe Built-In Predicates | Reference Manual | Alphabetic Index ]

compile(++File, +Module)

Compiles specified file or list of files File into the specified module Module.
Atom or string, or list of atoms or strings.


Similar to compile/1 except that the specified file or list of files is compiled into the specified module Module.

If the file contains no module/1 or module/3 directive, procedures that occur in File are written to the module Module (overwriting if necessary); the rest of the module remains unchanged. If the file contains a module directive it works like compile/1.

If Module does not exist, compile/2 will create such a module and compile File into it.

In addition to the exceptions listed below, any exception can occur during compilation, because general code may be executed in directives (:-/2), file queries (?-/2), macro transformations and inline expansion code.

Modes and Determinism


(4) instantiation fault
Either File or Module is not instantiated.
(5) type error
File is instantiated, but not to an atom or string, or a list of atoms or strings.
(5) type error
Module is instantiated, but not to an atom.
(61) inconsistent tool redefinition
A predicate that was already defined is later declared to be a tool.
(62) inconsistent procedure redefinition
Illegal attempt to change a predicate's properties like: tool, dynamic, demon, parallel, calling convention.
(82) trying to access a locked module
The module in which the clauses should be compiled is locked.
(94) trying to redefine an existing imported procedure
There is already am imported predicate of the same name.
(130) syntax error: illegal head
The head of a clause is not an atom or a compound term.
(131) syntax error: illegal goal
A subgoal in the body of a clause is not an atom, a compound term or a variable.
(134) procedure clauses are not consecutive
The clauses of a procedure are not consecutive.
(136) trying to redefine a built-in predicate
Attempt to redefine a built-in predicate without declaring it first.
(137) trying to redefine a procedure with another type
A procedure which was previously referenced as built-in or external is now defined as a regular one, or vice versa.
(139) compiled or dumped file message
This event is invoked at the end of each compiled file, by default it prints the compilation time and size of compiled code.
(143) compiled query failed
A query in the compiled file has failed. This is by default ignored and the compilation continues.
(145) procedure being redefined in another file
A procedure is being redefined in another file than the original one.
(147) compilation aborted
This event is raised just before a compilation is aborted because of an error.
(148) bad pragma
An unrecognised pragma was used in the code.
(171) File does not exist :
File does not exist.


   [hanoi].         % compiles the file hanoi.pl

   [eclipse]: sh('cat file1').
   [eclipse]: sh('cat file2').
   q(X) :- write(X).
   [eclipse]: [user], p.
    p :- write(hi).
    user compiled 92 bytes in 0.00 seconds
   [eclipse]: compile([file1, file2],b), p.
   /home/lp/user/file1 compiled 32 bytes in 0.02 seconds
   /home/lp/user/file2 compiled 92 bytes in 0.00 seconds
   hi               % p/0 not compiled into module eclipse
   [eclipse]: module(b).
   [b]: p.
   [b]: q(ho).

   % example showing use of relative pathnames.
   [eclipse]: sh('ls -FR /home/lp/user/pl').
   a.pl        util/

   b.pl        c.pl

   [eclipse]: sh('cat /home/lp/user/pl/a.pl').
   :- compile('util/b').

   [eclipse]: compile('/home/lp/user/pl/a', b).
   /home/lp/user/pl/util/b.pl compiled 92 bytes in 0.00 seconds

   /home/lp/user/pl/a.pl compiled 28 bytes in 0.00 seconds

   compile(file1,M).         (Error 4).
   compile(F,eclipse).         (Error 4).
   compile(file1, "b").      (Error 5).
   compile(file1/1, b).      (Error 5).
   compile(file,eclipse).      (Error 171).

See Also

compile / 1, compile_stream / 1, compile_term / 1, set_flag / 2, use_module / 1, pragma / 1, fcompile : fcompile / 1