XLISP > XLISP Plus  -  Previous | Next

defparameter


Type:   -   defined macro (closure)
Source:   -   init.lsp

Syntax

(defparameter symbol init-value)
symbol - an expression evaluating to a symbol
init-value - an initial value expression
returns - the value of symbol

Description

The 'defparameter' macro defines a user parameter [variable] with the name 'symbol'. A user parameter is supposed to be a variable that should not be changed by the program but is allowed to be changed by the user to adapt the behaviour of the program to his or her own needs. The 'symbol' is created with the initial value 'init-value' expression. If 'symbol' did exist, its previous value will be overwritten. 'defparameter' returns the value of 'symbol' as its result.

(defmacro defparameter (sym val) `(setq ,sym ,val))

Note: The 'defparameter' macro is intended to simplify porting code from Common Lisp to XLISP. XLISP does have a concept of 'parameter' variables so in XLISP a 'parameter' variable is the same as any other variable. 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.

Examples

(boundp 'mvyar)         ; returns NIL - doesn't exist
(defparameter myvar 7)  ; returns 7
(boundp 'myvar)         ; returns T
myvar                   ; returns 7

Common Lisp: In Common LISP, the definition of 'defparameter' is such that it returns the 'symbol' as its result, XLISP returns the value of 'symbol'. Common LISP supports a documentation string as an additional optional parameter, XLISP does not support this.

See also the XLISP Plus defconstant and defvar functions.

  Back to Top


XLISP > XLISP Plus  -  Previous | Next