Compiler Checking of Optimizing Conditions

AutoCAD AutoLISP & Visual LISP

 
Compiler Checking of Optimizing Conditions
 
 
 

The compiler always checks for optimizing consistency. If you specify an optimization option that contradicts certain security rules, the compiler will issue warning messages. The security rules are:

Link

The compiler directly links AutoLISP function calls only if the following conditions are met:

  • The function is defined only once, or is predefined by AutoLISP and no user defun redefines it.
  • The function name does not appear in the parameter list of another function.
  • The function is not assigned anywhere in the project.
Drop

The compiler tries to drop a function symbol only if all corresponding function calls are directly linked to the function definition. The compiler does not drop the symbol for a function definition if the program calls the function by its symbol name. A function is called by symbol in the following cases:

  • The symbol appears in a vl-acad-defun declaration.
  • The function was called from an ACTION_TILE action string.
  • The function symbol is a quoted argument for apply, mapcar, or eval somewhere in the project.

Note that for functions called from top-level expressions, the Drop declaration will be ignored without warning messages.

Localize

The compiler does not localize a variable in bound lists of defun, lambda, and foreach expressions if any of the following conditions are true:

  • The variable has a non-local reference (or assignment) to it within the outer top-level expression.
  • The variable is called as a function by name.
  • The variable symbol appears as a function call somewhere in the top-level read-eval loop.

Other than these conditions, which always cancel the optimization and result in warning messages, there are other conditions that may or may not result in incorrect code. Choose the Safe Optimize option for the project to disallow these conditions as well. Disabling Safe Optimization results in compiler warnings if these conditions are met. See Understanding Safe Optimization for more information on this topic.