The 'defconstant' macro defines a user constant with the name 'symbol'. The 'symbol' is created with the initial value 'init-value' expression. If 'symbol' did exist, its previous value will be overwritten. 'defconstant' returns the 'symbol' as its result.
(defmacro defconstant (sym val) `(setq ,sym ,val))
Note: The 'defconstant' macro does not define a constant in the sense of an 'unchangeable' value. It's only intended to simplify porting code from Common Lisp to XLISP. XLISP does not support a 'constant' data type and also raises no error if the 'init-value' gets changed by the program afterwards. This macro is not included in the standard Nyquist distribution. If you want to use it, copy the code above to your 'init.lsp' file.
(boundp 'mvyar) ; returns NIL - doesn't exist (defconstant myvar 7) ; returns 7 (boundp 'myvar) ; returns T myvar ; returns 7
Common Lisp: In Common Lisp, the definition of 'defconstant' is such that it returns the 'symbol' as its result, XLISP returns the value of 'symbol'. In Common Lisp, any change to the value of the 'defconstant symbol' is supposed to generate an error, XLISP treats it like any user symbol and allows it to change. Common LISP supports an additional documentation string as an optional parameter, XLISP does not support this.
See also the XLISP Plus defparameter and defvar functions.