2012-09-01 38 views

回答

5

我只想unintern派生類型說明符:

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] 

另外,如果你是真的關心刪除類型的每一絲出於某種原因,你總是可以編寫實現相關的代碼實現它,即使這些功能沒有在標準中提及。例如,在CCL(未經測試,我只是脫脂相關的代碼):

(defun delete-type (derived-type-specifier) 
    (ccl::clear-type-cache) 
    (remhash derived-type-specifier ccl::%deftype-expanders%) 
    (setf (documentation derived-type-specifier 'type) nil)) 

在這裏,我們去:

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]