Structure copying discrepancy?
drautb opened this issue · comments
The last koan in structures.lisp talks about shallow copying at the end. It looks like this:
;; note that the copying is shallow
(let ((shallow-copy (copy-american-football-player manning-1)))
(setf (car (nfl-guy-team manning-1)) "Giants")
(assert-equal ___ (car (nfl-guy-team manning-1)))
(assert-equal ___ (car (nfl-guy-team shallow-copy))))))
I expected the output the team for manning-1
to be "Giants"
, and the team for shallow-copy
to be "Colts"
. However, the result is that they're both "Giants"
.
;; note that the copying is shallow
(let ((shallow-copy (copy-american-football-player manning-1)))
(setf (car (nfl-guy-team manning-1)) "Giants")
(assert-equal "Giants" (car (nfl-guy-team manning-1)))
(assert-equal "Giants" (car (nfl-guy-team shallow-copy))))))
This looks more like deep copying, unless I'm misunderstanding something...
I'm using SBCL: SBCL 1.1.1.0.debian
shallow copy means only copy the first level, not more.
(nfl-guy-team shallow-copy) point to (nfl-guy-team manning-1), so both are "Giants"
As this issue has been answered/clarified and is apparently not bug-related, it seems like it could be closed, no?