From ffdcc3c6154aa5a77314e240621ff10a3e6c26e3 Mon Sep 17 00:00:00 2001 From: colin Date: Sat, 16 Sep 2023 10:06:21 -0700 Subject: Initial commit --- forget.lisp | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 forget.lisp (limited to 'forget.lisp') 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)))) -- cgit v1.2.3