The Amzi! Prolog compiler transforms Prolog source code files (.pro) into object code files (.plm). Source files must be plain text with no embedded control characters other than the newline.
The Compiler (and Linker) are automatically invoked in the IDE when you select Project | Rebuild Project or Project | Rebuild All. It is also invoked when you run or debug a compiled Prolog Projec.t
The net result of all of this work is that compiled code can run twenty or thirty times faster than equivalent interpreted code, occupies less space in memory and consumes much less space to execute.
We strongly recommend that as much code as possible be compiled once it has been developed.
The compiler does not, by default (no discontiguous or multifile specified), accomodate split definitions of predicates. It compiles the separated clusters of continguous clauses as separate chunks of compiled code, each with the same name. So when you try to load the compiled program, when the loader reaches the second definition of a predicate you will get an error message indicating you have attempted to redefine a compiled predicate.
There are also directives for defining a collection of predicates with a public interface called a module--see Modules for details.
Any compilation problems will be added to the Tasks View.
When you click on an error in the Tasks View the editor will position the cursor in the source file where the error was found.
acmp [source], [object], [listing] [source] the name of the source file (.pro) [object] the name of the object file to be created (.plm) [listing] the name of the optional listing file (PAL)To use compile in prompting mode, do not specify any arguments.
c> acmp source file [.PRO] : object file [.PLM] : listing file [.PAL] :For example:
c> acmp Amzi! Prolog Compiler Copyright (c) 1987-2000 Amzi! inc. All Rights Reserved. Source Code [.PRO]: duck2 Object Code [duck2.PLM]: Listing File [NULL.PAL]: duck2 Compiling duck2.pro |- main / 0 |- go / 0 |- go / 0 |- go / 0 [CodeSize 410 Bytes, Compile time 11 seconds.]or
c> acmp duck1 ...
|- Name / Arity_Pred_1_Clause_1 |- Name / Arity_Pred_2_Clause_2 |- ...If an error occurs a message will be printed to the screen and the error handler will be invoked. Most errors will be syntax errors. In the case of a syntax error, the offending term will be listed along with the error message.
Note that when the compiler reads in clauses it does so by reading in all clauses for a given predicate and the first clause of the following predicate. Thus it is possible for a read error to occur in a clause which is not in the predicate being compiled but is in the next predicate to be compiled.
Errors in a clause will cause the compilation of that clause to be skipped; compilation continues with the next clause.
The compiler output is especially useful for tracking down errors due to unintentional split-definition clauses, or "missing" predicates lost by a misplaced period. By viewing the listing you can see if all the clause definitions are contiguous, and if all the predicates you thought were in the file actually were.
You might also run into difficulties loading programs that contain predicates with large numbers of clauses. The .cfg file parameters maxclauses, destbuf and srcbuf can all be used to increase the capacity of the Prolog engine when loading a compiled program.
The compiler optimizes its processing of clauses with only one or zero goals in the body. This permits such clauses to be compiled more quickly. This optimization has no effect on the resulting compiled code (it just arrives at it sooner).
The downside of this is a slight chance that such a clause will cause a stack to overflow on compilation. This is usually due to having very complex clauses, e.g.,
options( [option1, ..], [option2, ..], ... [option30, ..] ).To resolve this problem, cast the clause in the following form:
options(X1, X2, .., X30) :- X1 = [option1,..], ... X30 = [option30,..].By forcing the clause to have a more complex body (and a simpler head) the optimization technique described above will not be used by the compiler.
Where it is a problem try dividing predicates into two or more predicates, e.g.,
head1 :- body1. head1 :- body2. .. head1 :- body100.can be replaced with a slight performance penalty by:
head1 :- body1. .. head1 :- body50. head1 :- head2. % New link to remaining clauses head2 :- body51. .. head2 :- body100.
main :- run_user_program.
Then when the application loads it will immediately try to prove the user-written predicate run_user_program.
Copyright ©1987-2011 Amzi! inc. All Rights Reserved. Amzi! is a registered trademark and Logic Server is a trademark of Amzi! inc.