LispWorks User Guide and Reference Manual > 27 The COMMON-LISP Package

NextPrevUpTopContentsIndex

compile

Function
Summary

Compiles 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 not nil , 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 is nil the compiled function definition itself. Such compiled-function objects are not printable (but see disassemble) 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.

Warning messages are printed to *error-output* . Other messages are printed to *standard-output* .

Compatibility note

In LispWorks 5.1 and previous versions, warning messages are printed to *standard-output* .

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

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

See also

compile-file
disassemble
declare


LispWorks User Guide and Reference Manual - 22 Dec 2009

NextPrevUpTopContentsIndex