Does Common Lisp provide a facility for undefining types created with deftype?
I've not found anything in the Hyperspec about it.
I would just unintern
the derived type specifier:
T1> (deftype foo () 'fixnum)
FOO
T1> (let ((bar 1))
(check-type bar foo))
NIL
T1> (unintern 'foo)
T
T1> (let ((bar 1))
(check-type bar foo))
Unknown type specifier: FOO
[Condition of type SIMPLE-ERROR]
Also, if you are really concerned about deleting every trace of the type for some reason, you can always write implementation-dependent code to achieve it, even if such functionality is not mentioned in the standard. For example, in CCL (untested, I just skimmed the relevant code):
(defun delete-type (derived-type-specifier)
(ccl::clear-type-cache)
(remhash derived-type-specifier ccl::%deftype-expanders%)
(setf (documentation derived-type-specifier 'type) nil))
And here we go:
T1> (deftype foo () "frob" 'fixnum)
FOO
T1> (documentation 'foo 'type)
"frob"
T1> (let ((bar 1))
(check-type bar foo))
NIL
T1> (delete-type 'foo)
NIL
T1> (documentation 'foo 'type)
NIL
T1> (let ((bar 1))
(check-type bar foo))
Unknown type specifier: FOO
[Condition of type SIMPLE-ERROR]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With