Compatibility of defun with Previous Versions of AutoCAD

AutoCAD AutoLISP & Visual LISP

 
Compatibility of defun with Previous Versions of AutoCAD
 
 
 

The internal implementation of defun changed in AutoCAD 2000. This change will be transparent to the great majority of AutoLISP users upgrading from earlier versions of AutoCAD. The change only affects AutoLISP code that manipulated defun definitions as a list structure, such as by appending one function to another, as in the following code:

(append s::startup (cdr mystartup))

For situations like this, you can use defun-q to define your functions. An attempt to use a defun function as a list results in an error. The following example illustrates the error:

_$ (defun foo (x) 4)
foo
_$ (append foo '(3 4))
; error: Invalid attempt to access a compiled function definition.
You may want to define it using defun-q: #<SUBR @024bda3c FOO>

The error message alerts you to the possibility of using defun-q instead of defun.

The defun-q function is provided strictly for backward compatibility with previous versions of AutoLISP and should not be used for other purposes. For more information on using defun-q, and the related defun-q-list-set and defun-q-list-ref functions, see the AutoLISP Reference.