Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!ut-sally!husc6!think!ames!ptsfa!ihnp4!inuxc!iuvax!pur-ee!uiucdcs!uiucdcsp!johnson From: johnson@uiucdcsp.cs.uiuc.edu Newsgroups: comp.lang.smalltalk Subject: Re: literals Message-ID: <80500009@uiucdcsp> Date: Tue, 7-Jul-87 10:31:00 EDT Article-I.D.: uiucdcsp.80500009 Posted: Tue Jul 7 10:31:00 1987 Date-Received: Sat, 11-Jul-87 06:46:26 EDT References: <938@argus.UUCP> Lines: 16 Nf-ID: #R:argus.UUCP:938:uiucdcsp:80500009:000:927 Nf-From: uiucdcsp.cs.uiuc.edu!johnson Jul 7 09:31:00 1987 * I've been working on a variation of the smalltalk model and in studying *the VM I've found that if you have a string constant in a method and assign it *to an instance variable and somewhere down the line you make a modification to *that string, that the constant in the method would hence change. Is this *correct? And if so, I see it as a major flaw that you would be able to modify *a constant! That is correct. It is one of several flaws in the language design. It is no real consolation, but this particular problem can be avoided by using symbols instead of strings, since symbols are not modifiable. However, the problem resurfaces with "constant" arrays. There probably need to be more unchangeable classes, and all constants need to be one of them. If you want to use a constant as the initial state of an object then you should make a copy of it. Note that constants like SmallIntegers cannot be modified.