Path: utzoo!mnetor!uunet!husc6!necntc!rayssd!trr From: trr@rayssd.ray.com (Terry R. Raymond) Newsgroups: comp.lang.smalltalk Subject: Question concerning behavior of assignment and copy methods Message-ID: <1868@rayssd.ray.com> Date: 25 Mar 88 23:14:27 GMT Sender: trr@rayssd.ray.com (Terry R. Raymond @ Raytheon Company, Portsmouth RI) Organization: Raytheon Company, Portsmouth RI Lines: 63 I am using Smalltalk/V and would like to know if the following methods behave the same way in Smalltalk-80. The methods of concern are; assignment, shallowCopy and deepCopy. The expressions below demonstrate their behavior. Would somebody who uses Smalltalk-80 please inform me if the methods behave the same way in Smalltalk-80. The expressions were evaluated with "Show it". Assignment | a b | a := #(23 45 78). b := a. b at: 1 put: 93. ^a The result was (93 45 78). Shallow copy | a b | a := #(23 45 78). b := a shallowCopy. b at: 1 put: 93. ^a The result was (23 45 78). | a b | a := #(23 (45 56) 78). b := a shallowCopy. (b at: 2) at: 1 put: 93. ^a The result was (23 (93 56) 78). Deep Copy The first example was the same as shallowCopy. | a b | a := #(23 (45 56) 78). b := a deepCopy. (b at: 2) at: 1 put: 93. ^a The result was (23 (45 56) 78). | a b | a := #(23 (45 (56 78) 91) 84). b := a deepCopy. ((b at: 2) at: 2) at: 1 put: 99. ^a The result was (23 (45 (99 78) 91) 84). -- Terry Raymond Raytheon Submarine Signal Division; Portsmouth RI; (401)-847-8000 x5597 smart mailer or arpanet: trr@rayssd.ray.com old dumb mailer or uucp: {cbosgd,gatech,ihnp4,linus!raybed2} !rayssd!trr