Parsing Numbers (was: Re: Exponents of numbers)

David T. Lewis lewis at mail.msen.com
Fri Sep 16 10:40:44 UTC 2005


On Thu, Sep 15, 2005 at 03:48:37PM -0400, Andreas Raab wrote:
> (changing title to fit thrust of discussion better)
> 
> [e, q, d as exponents]
> >> Why??? This seems completely superfluous and causes actual harm if  
> >> you happen to misspell a hex constant.
> > 
> > Well, the obvious choice is e which still would be a hex digit. The  
> > Blue Book only has e, btw.
> > 
> > I had a conversation with Dan once about Smalltalk's syntax for  literal 
> > numbers and he was quite proud of the purely syntactical  rules enabled 
> > by distinguishing upper and lower case.
> 
> That's not my point, which is: Why do we need "d" and "q" *in addition* 
> to "e"? Note that this is a recent addition - it has been added to 3.8 
> with update 6482NumberReadFromFixes-2-dtl which claims that
> 
> 	"These changes correct several problems with parsing of numbers from 
> strings and streams. The problems are demonstrated by NumberParsingTest 
> and ScaledDecimalTest (provided in separate change sets; the latter is 
> already included in the Squeak 3.9 image)."
> 
> Unfortunately, the only thing that relates to the behavior in question 
> are two tests which "confirm" that behavior. So again: Why "d" and "q"? 
> What do we need that for?

Hi Andreas,

I wrote the tests that document the "d" and "q" behavior. To the
best of my (admittedly hazy) recollection, the reason for this was
that I wanted to fix a specific problem with parsing ScaledDecimals:

	'1.40s2' asNumber => 1.39s2

And I wanted to fix this without making any other modifications to
Squeak's number parsing as of that time, which was Squeak 3.7.

The tests document the actual behavior of Squeak 3.7, which did the
following:

123e4 => 1230000
123d4 => 1230000
123q4 => 1230000
123z4 => error

I have no idea why Squeak 3.7 accepted this syntax, but it did, so I
left it alone and "documented" it in the tests.

Squeak 3.6 does not accept the "d" or "q" syntax, and the purple book
does not say anything about it either.

Bottom line: Unless someone can think of a reason for the "d" and "q"
syntax to be there, it is just another bug. If so, both the tests and
the implementation should be changed to get rid of the "d" and "q"
stuff.

Dave




More information about the Squeak-dev mailing list