6 Compiling Lisp Programs

6.1 About the Compiler

The Compiler reads Lisp expressions and generates native machine code that runs faster than the interpretation of the original source code. Compiled code generally produces the same values and has the same side effects as the interpretation of the original source code.

The Compiler has two compilation modes: one that emphasizes fast compilation and one that emphasizes efficient compiled code. The default compilation mode is development mode, which compiles code quickly but performs only some optimizations. The default mode is convenient when you are developing code because it allows you to combine editing code with compiling and testing code. Rapid compilation also makes it convenient to compile a file to check for syntax errors.

When you are ready to fully optimize code, you can switch to the production mode of the Compiler. In this mode, the Compiler uses information you provide in the source code to produce efficient compiled code. You should use the production mode after you have debugged and tested your program.

This chapter explains how to compile functions and files, describes how to control compilation with keyword arguments, and describes Compiler messages. It does not discuss Compiler optimizations; for information on how to increase the efficiency of source code and for a description of the automatic optimizations performed by the Compiler, see Chapter 3, "Optimizing Lisp Programs" in The Advanced User's Guide. The information in this chapter applies to both compilation modes of the Compiler unless otherwise noted.

The constructs listed below are described in this chapter. Section 6.2 on page 114 gives complete syntactic descriptions of these functions and forms.

compile
compile-file
compiled-function-p
compiler-options
disassemble
eval-when
uncompile

6.1.1 - Compiling functions and files
6.1.2 - Setting Compiler options
6.1.3 - Compiler messages and warnings
6.1.4 - Maintaining package compatibility in compiled files

The User's Guide - 9 SEP 1996

Generated with Harlequin WebMaker