Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!cec2!news From: flan@cics.wustl.EDU (Ian Flanigan) Newsgroups: comp.lang.lisp Subject: Problems Copying Structures Keywords: defstruct structures death copying Message-ID: <1990Dec8.071142.5318@cec1.wustl.edu> Date: 8 Dec 90 07:11:42 GMT Sender: news@cec1.wustl.edu (USENET News System) Reply-To: flan@cics.wustl.EDU (Ian Flanigan) Organization: Center for Intelligent Computing Systems Lines: 73 I've run into a big, big snag using AKCL 1.492. I think it's a general problem with Common Lisp, but here goes: In my program I define a structure with defstruct: (defstruct hexboard (board (make-array (list x-board-dimension y-board-dimension) :element-type 'character :initial-element #\Space)) (ownership-list (make-array number-of-playersi :element-type 'list :initial-element NIL)) (connection-list (make-array (list x-board-dimension y-board-dimension) :element-type 'list :initial-element NIL)) ) Then I create an instance of the structure with: > (setq x (make-hexboard)) Now I try to make a copy of that structure: > (setq y (copy-hexboard x)) And change a few things: > (setf (aref (hexboard-board y) 0 0) #\X) Now I try to see what y is: > y #S(HEXBOARD BOARD #2A((#\X #\Space #\Space #\Space #\Space #\Space) (#\Space #\Space #\Space #\Space #\Space #\Space) (#\Space #\Space #\Space #\Space #\Space #\Space) (#\Space #\Space #\Space #\Space #\Space #\Space) (#\Space #\Space #\Space #\Space #\Space #\Space) (#\Space #\Space #\Space #\Space #\Space #\Space)) OWNERSHIP-LIST #(NIL NIL) CONNECTION-LIST #2A((NIL NIL NIL NIL NIL NIL) (NIL NIL NIL NIL NIL NIL) (NIL NIL NIL NIL NIL NIL) (NIL NIL NIL NIL NIL NIL) (NIL NIL NIL NIL NIL NIL) (NIL NIL NIL NIL NIL NIL))) Now I see what x is: > x #S(HEXBOARD BOARD #2A((#\X #\Space #\Space #\Space #\Space #\Space) (#\Space #\Space #\Space #\Space #\Space #\Space) (#\Space #\Space #\Space #\Space #\Space #\Space) (#\Space #\Space #\Space #\Space #\Space #\Space) (#\Space #\Space #\Space #\Space #\Space #\Space) (#\Space #\Space #\Space #\Space #\Space #\Space)) OWNERSHIP-LIST #(NIL NIL) CONNECTION-LIST #2A((NIL NIL NIL NIL NIL NIL) (NIL NIL NIL NIL NIL NIL) (NIL NIL NIL NIL NIL NIL) (NIL NIL NIL NIL NIL NIL) (NIL NIL NIL NIL NIL NIL) (NIL NIL NIL NIL NIL NIL))) How can I get it so that there are no side affects? I've tried copy-tree, but that doesn't work. I can't think of anything else to do. Any help would be greatly appreciated. Thanks. -- Ian Flanigan flan@cics.wustl.edu "You can never have too many napkins." wucs1.wustl.edu!cics!flan@uucp