6
Common Lisp는 deftype으로 생성 된 타입을 정의 해제하는 기능을 제공합니까?Common Lisp에서 타입 삭제하기
나는 Hyperspec에서 그것에 대해 아무것도 발견하지 못했습니다.
는Common Lisp는 deftype으로 생성 된 타입을 정의 해제하는 기능을 제공합니까?Common Lisp에서 타입 삭제하기
나는 Hyperspec에서 그것에 대해 아무것도 발견하지 못했습니다.
는난 그냥 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]
, 당신은 항상로 구현 의존적 인 코드를 작성할 수 있습니다 이러한 기능이 표준에 언급되지 않은 경우에도이를 달성하십시오.
(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]
예를 들어, CCL에 (테스트되지 않은, 그냥 관련 코드를 미끄러 져)