[BUG?] (Symbol readFromString: '#Smalltalk') class ~~ Symbol

agree at carltonfields.com agree at carltonfields.com
Tue Oct 5 22:48:58 UTC 1999


> As part of testing #readFromString:, we noticed that
> > 	(Symbol readFromString: '#Smalltalk') class == String.
> > when we expected
> > 	(Symbol readFromString: '#Smalltalk') class == Symbol.
> > What do others think? Is this a bug? Should we fix it?

The far more onerous problem is not so much that the class of the expression is String, but that the VALUE of the expression is ''!

This derives from the fact that Symbol is a subclass of String (adding the interning functionality), and that String overrides the definition in Object which, I believe would have returned the correct value.  

For example, 

	(Object readFromString: '#abc') class

yields the expected result.

Since String expects a string, and an expression beginning without a "'" is not a string, well, you know.

So the entire thing devolves to asking the question, what are the expected semantics of the "readFrom:" operation?  While it is true that

	LargePositiveInteger readFromString: '123'

returns a SmallInteger and

	SmallInteger readFromString: '123123123123123'

returns a LargePositiveInteger, would this be considered aberrant behavior, or the correct result?

Clearly, we expect the Symbol example above to behave more like the Object example, not because of the CLASS returned, so much as because of the actual result given.                                   





More information about the Squeak-dev mailing list