2012-09-01 17 views
6

Common Lispには、deftypeで作成した型の定義を解除する機能がありますか?Common Lispで型を削除する

私はそれについてHyperspecに何も見つかりませんでした。

私はちょうど unintern派生型指定子です

答えて

5

:あなたには、いくつかの理由のタイプのすべてのトレースを削除することについて本当に心配している場合

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] 
関連する問題