Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!clyde!cbosgd!ihnp4!ptsfa!ames!ucbcad!ucbvax!decvax!tektronix!tekcrl!tekchips!jans From: jans@tekchips.UUCP Newsgroups: comp.lang.smalltalk Subject: Re: Re: literals Message-ID: <1429@tekchips.TEK.COM> Date: Wed, 8-Jul-87 19:10:23 EDT Article-I.D.: tekchips.1429 Posted: Wed Jul 8 19:10:23 1987 Date-Received: Sat, 11-Jul-87 15:32:05 EDT Organization: Tektronix Inc., Beaverton, Or. Lines: 34 > > > >* 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... 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... Note that >constants like SmallIntegers cannot be modified. *That* is the flaw in the language! SmallIntegers are not bona fide objects! >...this particular problem can be avoided by using symbols instead of strings, >since symbols are not modifiable. Wrongo. Try x _ #flubber. x basicAt: 3 put: $i. Symbols are objects, and like all other objects, they may entertain requests to change their contents. The flaw in this case is not with the language, but with the understanding of what is happening. As someone else pointed out, there is no such thing as a constant object in Smalltalk. (SmallIntegers aren't really objects.) One could easily "demonstrate" that English is "flawed" with respect to certain Eskimo tongues, since English lacks 30 odd words for describing frozen water. However, excepting Alaska, English has little use for such a facility, having instead thousands of words for technical terms, words that are borrowed by other languages around the globe. Smalltalk suffers not from it's lack of constants, but rather from biased notions of what a language should be. You want a constant? Subclass and override all the accessing protocol!