[ ECLiPSe Predicate Database built-in.|Group Index| Full 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_interface/1 or begin_module/1 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)
A system predicate is being redefined.
(82)
The module in which the clauses should be compiled is locked.
(130)
The head of a clause is not an atom or a compound term.
(131)
A subgoal in the body of a clause is not an atom or a compound term.
(134)
The clauses of a procedure are not consecutive.
(135)
Trying to redefine a protected procedure.
(137)
A procedure which was previously referenced as built-in or external is now defined as a regular one, or vice versa.
(143)
A query in the compiled file has failed.
(171)
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, lib / 2, set_flag / 2, use_module / 1, dbgcomp / 0, nodbgcomp / 0