[squeak-dev] Code Jeopardy

Bert Freudenberg bert at freudenbergs.de
Fri May 6 12:24:15 UTC 2016

On 06.05.2016, at 10:21, Stéphane Rollandin <lecteur at zogotounga.net> wrote:
>> After taking a closer look at how the parsing needs to work, I see that
>> fixing this (by issuing a warning) may be easier said than done. Maybe that's
>> why no one has fixed it yet :-(
> But is it really a problem ? It arises only because one abuses syntatic sugar and can be fixed by writing
> {
> 25rFFs2.
> 26rFFs2.
> 27rFFs2.
> 28rFFs2.
> 29rFFs2.
> 30rFFs2.
> 31rFFs2.
> 32rFFs2
> }
> instead.
> Stef

Writing it that way does not make any difference. Some of these are parsed as ScaledDecimal, some as Integer. That is surprising, unexpected, and potentially leads to bugs.

Dan designed the number parsing to be context-independent. Uppercase letters were digits in bases > 10, certain lowercase letters have special meaning (r, e, d, q, s). This leads to a rather simple syntax.

When we made the change to allow lower-case letters for digits, number parsing became ambiguous. That’s why the result of the expression above is surprising, because the parsing rules are no longer simple and universal, but depend on the radix.

The only compelling reason for introducing the change was to allow lower-case hex numbers (as Eliot pointed out).

How about we special-case radix 16, to be the only one that allows lowercase digits for plain integers? In general we would only allow uppercase digits, and the lowercase special modifiers. But if the radix was 16, the rest of the number would be parsed as an case-independent hex integer without modifiers.

Another idea would be to allow 0x as a modifier (similar to 16r) to indicate a hex integer with both upper and lower-case digits.

I actually like the latter, the only problem would be that code using lower-case hex numbers would have to be rewritten.

- Bert -

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4207 bytes
Desc: not available
Url : http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20160506/793fdb11/smime.bin

More information about the Squeak-dev mailing list