[ 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.
File
Atom or string, or list of atoms or strings.
Module
Atom.

Description

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

Exceptions

(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.

Examples

Success:
   [hanoi].         % compiles the file hanoi.pl

   [eclipse]: sh('cat file1').
   p.
   yes.
   [eclipse]: sh('cat file2').
   q(X) :- write(X).
   yes.
   [eclipse]: [user], p.
    p :- write(hi).
    user compiled 92 bytes in 0.00 seconds
   hi
   yes.
   [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
   yes.
   [eclipse]: module(b).
   [b]: p.
   yes.
   [b]: q(ho).
   ho.
   yes.


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

   /home/lp/user/pl/util:
   b.pl        c.pl

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

   yes.
   [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
   yes.

Error:
   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