function

AutoCad AutoLISP Functions

 
function
 
 
 

Tells the Visual LISP compiler to link and optimize an argument as if it were a built-in function

(function symbol | lambda-expr) 

The function function is identical to the quote function, except it tells the Visual LISP compiler to link and optimize the argument as if it were a built-in function or defun.

Compiled lambda expressions that are quoted by function will contain debugging information when loaded into the Visual LISP IDE.

Arguments

symbol

A symbol naming a function.

lambda-expr

An expression of the following form:

(LAMBDA arguments {S-expression}* )

Return Values

The result of the evaluated expression.

Examples

The Visual LISP compiler cannot optimize the quoted lambda expression in the following code:

(mapcar
  '(lambda (x) (* x x))
       '(1 2 3))

After adding the function function to the expression, the compiler can optimize the lambda expression. For example:

(mapcar
   (function (lambda (x) (* x x)))
      '(1 2 3))