Next Prev Up Top Contents Index

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 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.

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 Reference Manual - 13 Jun 2003

Next Prev Up Top Contents Index