Use of a counter in a list

"steph.tougard via Sbcl-help" <[email protected]>
Newsgroups gmane.lisp.steel-bank.general
Message-ID <lTkfoAbl45MDiVpQcxhYBwYrXUXyV6rFJio9EAv5oHaeX2ueSSOaWR90Qc1R0bDZ9iHQ1kS3iEPsarENJ5JXRnq361ksHWA0gRutfSD4Hvo=@pm.me>
Hi,

I don't understand why this code does not work with SBCL while it works perfectly with ABCL and CLISP

(let ((a '(0)))
(defun inc-a () (incf (car a))) (defun a () (car a)))

On SBCL

CL-USER> (a)
0 (0 bits, #x0, #o0, #b0)
CL-USER> (inc-a)
1 (1 bit, #x1, #o1, #b1)
CL-USER> (a)
0 (0 bits, #x0, #o0, #b0)CL-USER>

On CLISP or ABCL

[2]> (a)
0
[3]> (inc-a)
1
[4]> (a)
1[5]>

Even more worrying to me, I get the same result with (sb-ext:atomic-incf), the (a) function always returns 0.

Please, can you explain to me like I'm 5 years old why it does not work on SBCL and why it works with other LISP compilers ?

_______________________________________________
Sbcl-help mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sbcl-help
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.