[BUG] equivalence between strings and symbols

Lex Spoon lex at cc.gatech.edu
Mon Apr 10 10:01:01 UTC 2000


"John W. Sarkela" <john_sarkela at 4thEstate.com> wrote:
> Conclusion: a string and a symbol should never be equivalent
> Proposed Solution: redefine #= in String to exclude equivalence
> with Symbols.
> 


Man, everyone quietl agrees that a symbol "obviously" can't be
equal to a string.  However, consider this implementation:

	Symbol>>= anObject
		self class == anObject class ifTrue: [
			^self == anObject ].
		^super = anObject

This implementation allows #abc = 'abc', but the performance should
still be very good when comparing two symbols.

I kinda like #abc = 'abc'.  I doubt anyone will be terribly surprised by
this, any more than they are surprised by 2.0 = 2.  Furthermore, Symbols
and Strings are mostly supposed to be the same; it's just that Symbols
are faster at certain things--why not keep their behavior
as similar as possible?



Lex





More information about the Squeak-dev mailing list