Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!samsung!munnari.oz.au!murtoa.cs.mu.oz.au!charlie!aragorn!rad From: rad@aragorn.cm.deakin.oz.au (Robert Alan Dew) Newsgroups: comp.lang.smalltalk Subject: Re: Data-Hiding? Really?? Message-ID: <7961@charlie.OZ> Date: 18 Jan 90 03:38:19 GMT References: <4811d5e9.20b6d@apollo.HP.COM> Sender: root@charlie.OZ Reply-To: rad@aragorn.UUCP (Robert Alan Dew) Organization: Department of Computing & Mathematics - Deakin University Lines: 33 In article <4811d5e9.20b6d@apollo.HP.COM> yon@apollo.HP.COM (David Yon) writes: [ ... ] #| apple basket integer anotherApple | # # apple := Apple new. # apple setRipeness: 6. # basket := AppleBasket new. # basket putApple: apple. # anotherApple := basket getApple. # anotherApple setRipeness: 5 # basket inspect. # # You'll find that by setting the ripeness factor of the #anotherApple variable, it changed the state of the object in the #AppleBasket. So the ripeness of the Apple in the AppleBasket will #have been changed to five. On the surface, this appears to violate #the rule that only objects can change their own state. # # Any thoughts on this? The expression basket getApple returns the Apple instance with ripeness of 6, not another Apple instance. Hence the object anotherApple is the object apple. Robert Dew rad@aragorn.cm.deakin.oz.au Department of Computing and Mathematics Deakin University Geelong Victoria Australia 3217