Bug: Use of == for arithmetic equality

Wolfgang Helbig helbig at lehre.ba-stuttgart.de
Tue Feb 14 00:09:59 UTC 2006


Dan Ingalls <Dan.Ingalls at Post.Harvard.edu> wrote:
> Date: Mon, 13 Feb 2006 09:37:42 -0800
...
> happened not to intern (ie force unique instances of) SmallIntegers. 
> In this case the use of == to mean arithmetic equality will not work 
> properly.  In my opinion, all such occurrences in the system should 
> be eliminated ASAP;  == is not an arithmetic compare in any Smalltalk 
> I know of.

But #== and #= is equivalent in ST-80 as described in [Adele Goldberg,
David Robson: "Smalltalk-80 The Language", 1989, p 115]:

	Objects, that can not change their internal state are called immutable
objects. This means,
     that, once created, they are not destroyed and then recreated when
they are needed again.
     Rather, the 256 instances of Character are created at the time the
system is initialized and
	remain in the system.
	...
	Besides Characters, the Smalltalk-80 system includes SmallIntegers and
Symbols as immutable
	objects.

In the same book, there are expressions like

[p 139]
... we want to know how many of the Characters are a or A.
  count _ 0.
  letters do: [:each | each asLowercase  == $a
                              ifTrue: [count _ count + 1]]

[p 168]
Thus
  'a string' asSymbol == 'a string' asSymbol
answers true.

etc. It might be a bad style to use #== instead
of #=, but this "bad habit" is certainly not rooted in the usage of
curly-brace languages alone.

Now, my question. Are SmallIntegers, Characters and Symbols in Squeak
immutable objects in the sense of the above definition, i, e. not
destroyable? If not, why and when was it changed in Squeak. If they are
still immutable, why is this planned to be changed?

Greetings,

whg



More information about the Squeak-dev mailing list