3.1 Introduction to the Compiler
3.1.2 When to compile code Compiled code is generally faster than its interpreted counterpart, but it can also be harder to modify and debug than interpreted code. Compiled code generally does less error checking and retains less information about the environment than interpreted code does. As a result, where interpreted code would signal an error, compiled code might simply behave unexpectedly. Compiled code is also less responsive to redefinitions; in particular, changes to macro definitions that occur after compilation are not reflected in the behavior of the compiled code.
In general, as you increase the amount of optimization performed by the Compiler, you increase the differences between the compiled code and its original source code and consequently decrease the amount of available debugging information. Thus, you should gradually and incrementally compile and optimize your code to retain the best balance of debugging information, safety, and code speed. You can vary the emphasis from safety to optimization by using optimization declarations.
Most Lisp programmers work in repeated cycles of editing, compiling, and debugging portions of code. You could use the following pattern while developing code:
- Begin with interpreted code, because it is easier to edit and debug.
- Once a portion of code is free of interpreted errors, compile the code in the default compilation mode, which compiles code quickly and detects some mistakes but performs few optimizations on the compiled code. The default mode retains a high degree of safety.
- When your code has been tested, compile the code at the highest optimization level, which allows the Compiler to fully optimize code to produce high-performance production code.
The Advanced User's Guide - 9 SEP 1996
Generated with Harlequin WebMaker