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

Fail Conditions

None.

Resatisfiable

No.

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.
(66) trying to modify a system predicate
A system predicate is being redefined.
(82) trying to access a locked module
The module in which the clauses should be compiled is locked.
(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 or a compound term.
(134) procedure clauses are not consecutive
The clauses of a procedure are not consecutive.
(135) trying to redefine a protected procedure
Trying to redefine a protected procedure.
(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.
(143) compiled query failed
A query in the compiled file has failed.
(171) File does not exist :
File does not exist.
(275)
Trying to add delay clauses to a built-in or external procedure.

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