Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!wuarchive!gem.mps.ohio-state.edu!tut.cis.ohio-state.edu!ucbvax!agate!shelby!lindy!giant From: giant@lindy.Stanford.EDU (Buc Richards) Newsgroups: comp.lang.lisp Subject: Creating an array of structures Keywords: Defstruct, Make-array Message-ID: <5244@lindy.Stanford.EDU> Date: 17 Oct 89 22:45:29 GMT Sender: giant@lindy.Stanford.EDU (Buc Richards) Reply-To: giant@lindy.Stanford.EDU (Buc Richards) Organization: Stanford University Lines: 37 When I make an array of structures, any changes to any of the elements change all the elements. What am I dong wrong? Here is a simple case I ran on a NeXT and a MacII under Allegro Common Lisp with the same results. (defstruct cardtype card code) CARDTYPE (Setf tc (Make-array 25 :Element-type 'cardtype :Initial-element (make-cardtype))) #(#s(CARDTYPE :CARD NIL :CODE NIL) #s(CARDTYPE :CARD NIL :CODE NIL) #s(CARDTYPE :CARD NIL :CODE NIL) #s(CARDTYPE :CARD NIL :CODE NIL) #s(CARDTYPE :CARD NIL :CO DE NIL) #s(CARDTYPE :CARD NIL :CODE NIL) #s(CARDTYPE :CARD NIL :CODE NIL) #s(CA RD TYPE :CARD NIL :CODE NIL) #s(CARDTYPE :CARD NIL :CODE NIL) #s(CARDTYPE :CARD NIL :CODE NIL) ...) (Setf (cardtype-code (Aref tc 1)) 360) 360 tc #(#s(CARDTYPE :CARD NIL :CODE 360) #s(CARDTYPE :CARD NIL :CODE 360) #s(CARDTYPE :CARD NIL :CODE 360) #s(CARDTYPE :CARD NIL :CODE 360) #s(CARDTYPE :CARD NIL :CO DE 360) #s(CARDTYPE :CARD NIL :CODE 360) #s(CARDTYPE :CARD NIL :CODE 360) #s(CA RD TYPE :CARD NIL :CODE 360) #s(CARDTYPE :CARD NIL :CODE 360) #s(CARDTYPE :CARD NIL :CODE 360) ...) ---------------- Every element has the :code changed to 360. Thanks for any assistance. Rob Richards @ @ Stanford University -