[BUG] equivalence between strings and symbols

Stephan Rudlof sr at evolgo.de
Sat Apr 15 22:21:22 UTC 2000


"R. A. Harmon" wrote:
> 
> I think I found a fix that conforms to ANSI, especially for the
> <sequenceReadableCollection> #= message.
> 
> I changed:
> 
> SequenceableCollection >> #=
>         . . .
>     (self class == otherCollection class) ifFalse: [^ false].   "<- Chg."
>         . . .
> 
> Symbol class >> #hasInterned:ifTrue:
>         . . .
>                 (symbol notNil and:[aString size = symbol size and: [aString sameAs:
> symbol]]) ifTrue: [     "<- CHG was ="
>         . . .
> 
> Symbol class >> intern:
>         . . .
>                         ifFalse:[(aString size = symbol size and:[aString sameAs: symbol])      "<-
> CHG was ="

There is a problem:

String>>
sameAs: aString 
	"Answer whether the receiver sorts equal to aString. The  
	collation sequence is ascii with case differences ignored."
	^ (self
		compare: self
		with: aString
		collated: CaseInsensitiveOrder)
		= 2

uses CaseInsensitiveOrder, which isn't appropriate for '='-like
comparison.

> 
> Then remove String >> #=.
> 

Another question is, how much and *which* code has to be changed cause
it relies on
	'someString' = #someString
and
	#someString = 'someString'
.

> This seem (large grain of salt here) to work OK, but I haven't really tested
> it or done much work while these changes are in effect.

It's interesting to evaluate
	Smalltalk recompileAllFrom: 'Aardvark'.
and play around after a little bit.

Greetings,

Stephan

> 
> I'll feel more confident about it after I complete and successfully run
> Collection protocol test.  I'm holding off on doing these until the Camp
> Smalltalk SUnit changes and the ANSI Tests are posted, so it could be awhile.
> 
> 
> --
> Richard A. Harmon          "The only good zombie is a dead zombie"
> harmonra at webname.com           E. G. McCarthy
> Spencer, Iowa

-- 
Stephan Rudlof (sr at evolgo.de)
   "Genius doesn't work on an assembly line basis.
    You can't simply say, 'Today I will be brilliant.'"
    -- Kirk, "The Ultimate Computer", stardate 4731.3





More information about the Squeak-dev mailing list