aboutsummaryrefslogtreecommitdiff
path: root/forget.lisp
diff options
context:
space:
mode:
Diffstat (limited to 'forget.lisp')
-rw-r--r--forget.lisp39
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))))