Skip to main content

fmakunbound

fmakunbound Function

Syntax:

fmakunbound name → name

Pronunciation:

[ ef mak* n ba_und ] or [ ef m—ak* n ba_und ]

Arguments and Values:

name—a function name.

Description:

Removes the function or macro definition, if any, of name in the global environment.

Examples:

(defun add-some (x) (+ x 19)) → ADD-SOME 
(fboundp ’add-some) → true
(flet ((add-some (x) (+ x 37)))
(fmakunbound ’add-some)
(add-some 1))38
(fboundp ’add-some) → false

Exceptional Situations:

Should signal an error of type type-error if name is not a function name.

The consequences are undefined if name is a special operator .

See Also:

fboundp, makunbound

Data and Control

flet, labels, macrolet

Expanded Reference: fmakunbound

Removing a Function Binding

fmakunbound removes the function definition associated with a symbol, making it unbound in the function namespace.

(defun temp-helper (x) (* x 2))
(not (null (fboundp 'temp-helper)))
=> T
(temp-helper 5)
=> 10

(fmakunbound 'temp-helper)
(fboundp 'temp-helper)
=> NIL

Return Value

fmakunbound returns the symbol that was unbound, making it chainable or useful in expressions.

(defun foo () :foo)
(fmakunbound 'foo)
=> FOO

;; Calling the function now signals an error
(handler-case (foo)
(undefined-function (c)
(cell-error-name c)))
=> FOO

Removing setf Function Bindings

fmakunbound also works with (setf name) function names.

(defun (setf my-val) (new-value)
(declare (ignore new-value))
nil)

(not (null (fboundp '(setf my-val))))
=> T
(fmakunbound '(setf my-val))
(fboundp '(setf my-val))
=> NIL