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).
If not
nil
, this is the symbol that is to receive the compiled function as its global function definition.
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>
.
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.
(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