XLISP > XLISP Plus  -  Previous | Next

fmakunbound


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

Syntax

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

Description

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

(defun fmakunbound (sym)
  (setf (symbol-function sym) '*unbound*) sym)

Note: The 'fmakunbound' 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

(defun myfn () (print "hi"))  ; define MYFN
(myfn)                        ; prints "hi"
(fmakunbound 'myfn)           ; returns MYFN
(myfn)                        ; error: unbound function - MYFN

Caution: With 'fmakunbound' you can also unbind build-in functions!

Note: 'fmakunbound' 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 makunbound function.

  Back to Top


XLISP > XLISP Plus  -  Previous | Next