I'm reading chapter 5.2 of PAIP. And when I try define a constant using the following form, taken exactly from the book, I get the error shown below. I'm using SBCL 1.1.14.debian as the interpreter. What am I doing wrong?
(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)))
The error means that you have done a previous definition of the same name no-bindings with the value '(T T).
For instance in the REPL you have done a definition:
(defconstant no-bindings '(t t)
"Indicates pat-match success, with no variables.")
and then you have redefined no-bindings with:
(defconstant no-bindings '((t . t))
"Indicates pat-match success, with no variables.")
The manual specifies:
A constant defined by
defconstantcan 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.
Updated
Note that in SBCL, even a double definition of the same value, for instance, writing twice in the REPL:
(defconstant no-bindings '((t . t))
"Indicates pat-match success, with no variables.")
causes a constant redefinition error, while in other systems (I tried CCL), this does not happen. Actually this is due to the interpretation of "different value" in the above definition. The Glossary says the different is not the same, and same is not eql, and
(eql '((t . t)) '((t . t)))
gives NIL, while other equality operators, as, for instance:
(equal '((t . t)) '((t . t)))
returns T.
So, it seems that SBCL follows correctly the formal specification, differently from other systems.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With