- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在阅读 PAIP 的第 5.2 章。当我尝试使用完全取自本书的以下形式定义常量时,出现如下所示的错误。我使用 SBCL 1.1.14.debian 作为解释器。我做错了什么?
(defconstant no-bindings '((t . t))
"Indicates pat-match success, with no variables.")
The constant NO-BINDINGS is being redefined (from (T T) to ((T . T)))
最佳答案
该错误意味着您之前定义了同名no-bindings
,其值为'(T T)
。
例如在 REPL 中你做了一个定义:
(defconstant no-bindings '(t t)
"Indicates pat-match success, with no variables.")
然后您重新定义了 no-bindings
:
(defconstant no-bindings '((t . t))
"Indicates pat-match success, with no variables.")
manual指定:
A constant defined by
defconstant
can be redefined withdefconstant
. However, the consequences are undefined if an attempt is made to assign a value to the symbol using another operator, or to assign it to a different value using a subsequentdefconstant
.
已更新
请注意,在 SBCL 中,即使是相同值的双重定义,例如,在 REPL 中写入两次:
(defconstant no-bindings '((t . t))
"Indicates pat-match success, with no variables.")
导致持续的重新定义错误,而在其他系统(我试过 CCL)中,这不会发生。实际上这是由于上述定义中对“不同值”的解释。词汇表说不同的不是相同的,相同的不是 eql,
(eql '((t . t)) '((t . t)))
给出 NIL
,而其他相等运算符,例如:
(equal '((t . t)) '((t . t)))
返回 T
。
因此,与其他系统不同,SBCL 似乎正确地遵循了正式规范。
关于common-lisp - "constant is being redefined"与 defconstant?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31283475/
我正在阅读 PAIP 的第 5.2 章。当我尝试使用完全取自本书的以下形式定义常量时,出现如下所示的错误。我使用 SBCL 1.1.14.debian 作为解释器。我做错了什么? (defconsta
我正在尝试: (defconstant x 1) (cffi:foreign-alloc :int :initial-contents '(x 99)) 但我收到一条错误消息: The value
这个问题是关于 sbcl 的——或者我最初是这么想的。问题:什么时候角色不是角色?考虑以下代码: (defconstant +asc-lf+ #\Newline) (defconstant +a
我是一名优秀的程序员,十分优秀!