XLISP > XLISP Plus  -  Previous | Next

makunbound


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

Syntax

(makunbound symbol)
symbol - an expression evaluating to a symbol
returns - the symbol

Description

The 'makunbound' function makes a symbol's value unbound. The 'symbol' must be a valid symbol, but it does not need to have a value. The 'makunbound' function returns the symbol as its result.

(defun makunbound (sym)
  (setf (symbol-value sym) '*unbound*) sym)

Note: The 'makunbound' function is intended to simplify porting code from Common Lisp to XLISP. This function is not included in the standard Nyquist distribution. If you want to use it, copy the code above to your 'init.lsp' file.

Examples

(setq myvar "hi")    ; setup MYVAR "hi"
myvar                ; returns "hi"
(makunbound 'myvar)  ; returns MYVAR
myvar                ; error: unbound variable

Caution: With 'makunbound' you can also unbind internal XLISP variables like *obarray* or *readtable* !

Note: 'makunbound' is not misspelled, there is no 'e' in it.

Note: The fmakunbound function works on functions [closures] in the same way that the 'makunbound' function works on variables. Be sure to use the correct one for what you are unbinding. These functions do not generate an error if you try to unbind the wrong type. This is because of the definition of these functions and the fact that the function and variable name spaces are separate. [You can have both a function called FOO and a variable called FOO.]

See also the XLISP Plus fmakunbound function.

  Back to Top


XLISP > XLISP Plus  -  Previous | Next