
compile(+File,+Module)

   Compiles specified file or list of files File into the specified module
Module.



Arguments
   +File               Atom or string, or list of atoms or strings.
   +Module             Atom.

Type
   Predicate Database and Compiler

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.




Resatisfiable
      No.

Fail Conditions
      None.



Exceptions
     4 --- Either File or Module is not instantiated.
     5 --- File is instantiated, but not to an atom or string, or a    list of atoms or strings.
     5 --- 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, set_flag / 2, use_module / 1, pragma / 1, fcompile : fcompile / 1
