"truly-the" 函数是什么?
What is the "truly-the" function?
在 SBCL 2.0.1 中,(macroexpand '(dolist (x '(1 2 3)) (princ x)))
returns:
(BLOCK NIL
(LET ((#:N-LIST385 '(1 2 3)))
(TAGBODY
#:START386
(UNLESS (ENDP #:N-LIST385)
(LET ((X (TRULY-THE (MEMBER 3 2 1) (CAR #:N-LIST385))))
(SETQ #:N-LIST385 (CDR #:N-LIST385))
(TAGBODY (PRINC X)))
(GO #:START386))))
NIL)
T
什么是TRULY-THE
?它似乎是非标准的,因为我在 Common Lisp HyperSpec 中找不到它。
TRULY-THE
和THE
有什么区别?
来自 SBCL manual:
Special Operator: truly-the [sb-ext] value-type form
Specifies that the values returned by form conform to the value-type, and causes the compiler to trust this information unconditionally.
Consequences are undefined if any result is not of the declared type -- typical symptoms including memory corruptions. Use with great care.
换句话说,the
运算符在某些情况下(例如具有高级别调试)编译为测试以检查指定类型的正确性,而 truly-the
指示编译器从不执行此检查。
在 SBCL 2.0.1 中,(macroexpand '(dolist (x '(1 2 3)) (princ x)))
returns:
(BLOCK NIL
(LET ((#:N-LIST385 '(1 2 3)))
(TAGBODY
#:START386
(UNLESS (ENDP #:N-LIST385)
(LET ((X (TRULY-THE (MEMBER 3 2 1) (CAR #:N-LIST385))))
(SETQ #:N-LIST385 (CDR #:N-LIST385))
(TAGBODY (PRINC X)))
(GO #:START386))))
NIL)
T
什么是TRULY-THE
?它似乎是非标准的,因为我在 Common Lisp HyperSpec 中找不到它。
TRULY-THE
和THE
有什么区别?
来自 SBCL manual:
Special Operator: truly-the [sb-ext] value-type form
Specifies that the values returned by form conform to the value-type, and causes the compiler to trust this information unconditionally.
Consequences are undefined if any result is not of the declared type -- typical symptoms including memory corruptions. Use with great care.
换句话说,the
运算符在某些情况下(例如具有高级别调试)编译为测试以检查指定类型的正确性,而 truly-the
指示编译器从不执行此检查。