Next Previous Up Top Contents Index

4 The COMMON-LISP Package

compile

Function

Summary

Compile a lambda expression into a code vector.
Package

common-lisp

Signature

compile name &optional definition => name, function

Arguments

definition

If supplied, this is a lambda-expression to be compiled.

If not supplied, then the lambda-expression used is the current definition of the name (in this case name must be a non-nil symbol with an uncompiled definition).

name

If notnil, this is the symbol that is to receive the compiled function as its global function definition.

Values

A single value is returned, being the name symbol if supplied, or when name isnil the compiled function definition itself. Such compiled-function objects are not printable (but seedisassemble) other than as# <compiled function for SYMBOL>.
Description

compile calls the compiler to translate a lambda expression into a code vector containing an equivalent sequence of host specific machine code. A compiled function typically runs between 10 and 100 times faster. It is generally worth compiling the most frequently called Lisp functions in a large application during the development phase. The compiler detects a large number of programming errors, and the resulting code runs sufficiently faster to justify the compilation time, even during development.
Examples

(defun fn (...) ...) ; interpreted definition for fn

(compile 'fn         ; replace with compiled ; definition

(compile nil '(lambda (x) (* x x)))                   ; returns compiled squaring function

(compile 'cube '(lambda (x) (* x x x)))                   ; defun and compile in one

Notes

Seedeclare for a list of the declarations that alter the behavior of the compiler.
See also

compile-file
disassemble
declare


LispWorks Reference Manual - 15 Oct 1998

Next Previous Up Top Contents Index

Generated with Harlequin WebMaker