diff options
author | colin <colin@cicadas.surf> | 2023-09-16 10:06:21 -0700 |
---|---|---|
committer | colin <colin@cicadas.surf> | 2023-09-16 10:06:21 -0700 |
commit | ffdcc3c6154aa5a77314e240621ff10a3e6c26e3 (patch) | |
tree | 41e85718cad4e939a9c953f33a5348c830fdf282 /forget.lisp |
Initial commitmaster
Diffstat (limited to 'forget.lisp')
-rw-r--r-- | forget.lisp | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/forget.lisp b/forget.lisp new file mode 100644 index 0000000..cd2444e --- /dev/null +++ b/forget.lisp @@ -0,0 +1,39 @@ +;;;; forget.lisp + +(in-package #:forget) + +(defun forget (symbol &key + (function? t) + (value? t) + (class? t) + (plist? t) + (interns? t) + (package? nil)) + "Uninterns and forgets everything about a symbol" + (assert (symbolp symbol) (symbol) "~s is not a symbol." symbol) + + (when (and function? (fboundp symbol)) + (warn "Unbinding function ~s" symbol) + (fmakunbound symbol)) + + (when (and value? (boundp symbol)) + (warn "Unbinding value ~s" symbol) + (makunbound symbol)) + + (when (and class? (find-class symbol nil)) + (warn "Unbinding class ~s" symbol) + (setf (find-class symbol) nil)) + + (when (and plist? (symbol-plist symbol)) + (warn "Dropping symbol-plist on ~s" symbol) + (setf (symbol-plist symbol) nil)) + + (when interns? + (warn "Uninterning ~s from ~s" + symbol + (package-name (symbol-package symbol))) + (unintern symbol (symbol-package symbol))) + + (when (and package? (find-package symbol)) + (warn "Deleting package ~s" (package-name (find-package symbol))) + (delete-package (find-package symbol)))) |