Code Jeopardy

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
17 messages Options
Reply | Threaded
Open this post in threaded view
|

Code Jeopardy

Tobias Pape
Hi all,

without executing, what does the following expression result in?

#(
25rFFs2
26rFFs2
27rFFs2
28rFFs2
29rFFs2
30rFFs2
31rFFs2
32rFFs2
)

Best regards
        -Tobias

Reply | Threaded
Open this post in threaded view
|

Re: Code Jeopardy

Bert Freudenberg

> On 04.05.2016, at 13:32, Tobias Pape <[hidden email]> wrote:
>
> Hi all,
>
> without executing, what does the following expression result in?
>
> #(
> 25rFFs2
> 26rFFs2
> 27rFFs2
> 28rFFs2
> 29rFFs2
> 30rFFs2
> 31rFFs2
> 32rFFs2
> )
>
> Best regards
> -Tobias

Interesting.

16rFFe4 used to be 16711680, now it’s 65508. Try these:

#(
10r1e4
11r1e4
12r1e4
13r1e4
14r1e4
15r1e4
16r1e4
17r1e4
18r1e4
)

Maybe we need to raise an error for certain combinations? Better than a surprise.

- Bert -






smime.p7s (5K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Code Jeopardy

Nicolas Cellier
In reply to this post by Tobias Pape
Hard to guess without trying indeed...

This was broken by Andreas Raab when we decided to accept lower case letter digits 16rff instead of 16rFF...
This broke the nice floating point with different radix too...
#(10r1.0e5 11r1.0e5 12r1.0e5  13r1.0e5  14r1.0e5  15r1.0e5 16r1.0e5)


2016-05-04 13:32 GMT+02:00 Tobias Pape <[hidden email]>:
Hi all,

without executing, what does the following expression result in?

#(
25rFFs2
26rFFs2
27rFFs2
28rFFs2
29rFFs2
30rFFs2
31rFFs2
32rFFs2
)

Best regards
        -Tobias




Reply | Threaded
Open this post in threaded view
|

Re: Code Jeopardy

Nicolas Cellier
In reply to this post by Bert Freudenberg
Anyway, there is Decimal in ScaledDecimal, so any specification of decimal places other than base 10 may end up being surprising.

2016-05-04 14:37 GMT+02:00 Bert Freudenberg <[hidden email]>:

> On 04.05.2016, at 13:32, Tobias Pape <[hidden email]> wrote:
>
> Hi all,
>
> without executing, what does the following expression result in?
>
> #(
> 25rFFs2
> 26rFFs2
> 27rFFs2
> 28rFFs2
> 29rFFs2
> 30rFFs2
> 31rFFs2
> 32rFFs2
> )
>
> Best regards
>       -Tobias


Interesting.

16rFFe4 used to be 16711680, now it’s 65508. Try these:

#(
10r1e4
11r1e4
12r1e4
13r1e4
14r1e4
15r1e4
16r1e4
17r1e4
18r1e4
)

Maybe we need to raise an error for certain combinations? Better than a surprise.

- Bert -









Reply | Threaded
Open this post in threaded view
|

RE: Code Jeopardy

Ron Teitelbaum
In reply to this post by Tobias Pape
hmmm

It's an array.  It looks like encoded numbers base 25 through 32 of hex FF
but not sure about the s2.  Because I'm not sure the numbers will evaluate
it could just error.  But let's say I'm wrong and this is something that
actually does work and I haven't seen it before, base 25-32 FF s2 something,
this will return an array of numbers.  

Not executing it was difficult :).  Looking forward to the answer.

All the best,
Ron Teitelbaum

> -----Original Message-----
> From: [hidden email] [mailto:squeak-dev-
> [hidden email]] On Behalf Of Tobias Pape
> Sent: Wednesday, May 04, 2016 7:33 AM
> To: The general-purpose Squeak developers list
> Subject: [squeak-dev] Code Jeopardy
>
> Hi all,
>
> without executing, what does the following expression result in?
>
> #(
> 25rFFs2
> 26rFFs2
> 27rFFs2
> 28rFFs2
> 29rFFs2
> 30rFFs2
> 31rFFs2
> 32rFFs2
> )
>
> Best regards
> -Tobias



Reply | Threaded
Open this post in threaded view
|

RE: Code Jeopardy

David T. Lewis
This looks like a good opportunity for public humiliation ;-)

I expect an eight element array of ScaledDecimal, each formatted with two
trailing zeros after the decimal point. The first value would be 25 * 16 +
15, and the last value would be 32 * 16 + 15. So I would expect the array
to contain these:

415.00
431.00
447.00
463.00
479.00
495.00
511.00
527.00

Dave


> hmmm
>
> It's an array.  It looks like encoded numbers base 25 through 32 of hex FF
> but not sure about the s2.  Because I'm not sure the numbers will evaluate
> it could just error.  But let's say I'm wrong and this is something that
> actually does work and I haven't seen it before, base 25-32 FF s2
> something,
> this will return an array of numbers.
>
> Not executing it was difficult :).  Looking forward to the answer.
>
> All the best,
> Ron Teitelbaum
>
>> -----Original Message-----
>> From: [hidden email] [mailto:squeak-dev-
>> [hidden email]] On Behalf Of Tobias Pape
>> Sent: Wednesday, May 04, 2016 7:33 AM
>> To: The general-purpose Squeak developers list
>> Subject: [squeak-dev] Code Jeopardy
>>
>> Hi all,
>>
>> without executing, what does the following expression result in?
>>
>> #(
>> 25rFFs2
>> 26rFFs2
>> 27rFFs2
>> 28rFFs2
>> 29rFFs2
>> 30rFFs2
>> 31rFFs2
>> 32rFFs2
>> )
>>
>> Best regards
>> -Tobias
>
>
>



Reply | Threaded
Open this post in threaded view
|

Re: Code Jeopardy

Nicolas Cellier

2016-05-04 18:40 GMT+02:00 David T. Lewis <[hidden email]>:
This looks like a good opportunity for public humiliation ;-)

I expect an eight element array of ScaledDecimal, each formatted with two
trailing zeros after the decimal point. The first value would be 25 * 16 +
15, and the last value would be 32 * 16 + 15. So I would expect the array
to contain these:

415.00
431.00
447.00
463.00
479.00
495.00
511.00
527.00

Dave


> hmmm
>
> It's an array.  It looks like encoded numbers base 25 through 32 of hex FF
> but not sure about the s2.  Because I'm not sure the numbers will evaluate
> it could just error.  But let's say I'm wrong and this is something that
> actually does work and I haven't seen it before, base 25-32 FF s2
> something,
> this will return an array of numbers.
>
> Not executing it was difficult :).  Looking forward to the answer.
>
> All the best,
> Ron Teitelbaum
>
>> -----Original Message-----
>> From: [hidden email] [mailto:[hidden email]
>> [hidden email]] On Behalf Of Tobias Pape
>> Sent: Wednesday, May 04, 2016 7:33 AM
>> To: The general-purpose Squeak developers list
>> Subject: [squeak-dev] Code Jeopardy
>>
>> Hi all,
>>
>> without executing, what does the following expression result in?
>>
>> #(
>> 25rFFs2
>> 26rFFs2
>> 27rFFs2
>> 28rFFs2
>> 29rFFs2
>> 30rFFs2
>> 31rFFs2
>> 32rFFs2
>> )
>>
>> Best regards
>>      -Tobias
>
>
>






Reply | Threaded
Open this post in threaded view
|

RE: Code Jeopardy

Ron Teitelbaum

Hi David,

 

Grr I should have guessed the scaled decimal! 

 

I saw the following emails about the issues you are pointing out.

 

Thanks!

 

Ron

 

From: Nicolas Cellier

 

 

2016-05-04 18:40 GMT+02:00 David T. Lewis <[hidden email]>:

This looks like a good opportunity for public humiliation ;-)

I expect an eight element array of ScaledDecimal, each formatted with two
trailing zeros after the decimal point. The first value would be 25 * 16 +
15, and the last value would be 32 * 16 + 15. So I would expect the array
to contain these:

415.00
431.00
447.00
463.00
479.00
495.00
511.00
527.00

Dave



> hmmm
>
> It's an array.  It looks like encoded numbers base 25 through 32 of hex FF
> but not sure about the s2.  Because I'm not sure the numbers will evaluate
> it could just error.  But let's say I'm wrong and this is something that
> actually does work and I haven't seen it before, base 25-32 FF s2
> something,
> this will return an array of numbers.
>
> Not executing it was difficult :).  Looking forward to the answer.
>
> All the best,
> Ron Teitelbaum
>
>> -----Original Message-----
>> From: [hidden email] [mailto:[hidden email]
>> [hidden email]] On Behalf Of Tobias Pape
>> Sent: Wednesday, May 04, 2016 7:33 AM
>> To: The general-purpose Squeak developers list
>> Subject: [squeak-dev] Code Jeopardy
>>
>> Hi all,
>>
>> without executing, what does the following expression result in?
>>
>> #(
>> 25rFFs2
>> 26rFFs2
>> 27rFFs2
>> 28rFFs2
>> 29rFFs2
>> 30rFFs2
>> 31rFFs2
>> 32rFFs2
>> )
>>
>> Best regards
>>      -Tobias
>
>
>


 



Reply | Threaded
Open this post in threaded view
|

Re: Code Jeopardy

Eliot Miranda-2
In reply to this post by Bert Freudenberg


On Wed, May 4, 2016 at 5:37 AM, Bert Freudenberg <[hidden email]> wrote:

> On 04.05.2016, at 13:32, Tobias Pape <[hidden email]> wrote:
>
> Hi all,
>
> without executing, what does the following expression result in?
>
> #(
> 25rFFs2
> 26rFFs2
> 27rFFs2
> 28rFFs2
> 29rFFs2
> 30rFFs2
> 31rFFs2
> 32rFFs2
> )
>
> Best regards
>       -Tobias


Interesting.

16rFFe4 used to be 16711680, now it’s 65508.



VisualWorks suffers exactly the same issue:

#(390 #s2 405 #s2 420 #s2 435 #s2 379264 419342 462150 507778) 

The only thing we can do is issue a warning, because otherwise we ban legal programs.  But we also need to disambiguate.  Should s or e in the penultimate positions force interpretation as scaled decimal or exponent, and hence force someone using a base >= 15 to use upper case?  Seems the only practical choice to me.  So we need tests and to modify printing.  At least we still print in upper case.  

And BTW, I for one would hate having to enter hex constanrts in upper case.  Makes my VMMaker life much more difficult; all the disassemblers and debuggers I use print hex in lower case.



 
Try these:

#(
10r1e4
11r1e4
12r1e4
13r1e4
14r1e4
15r1e4
16r1e4
17r1e4
18r1e4
)

VW refuses to parse these (non-decimal integers cannot have exponents, and if one adds a decimal point, non-radix 10 numbers cannot contain a decimal point.
 
Maybe we need to raise an error for certain combinations? Better than a surprise.


Reply | Threaded
Open this post in threaded view
|

Re: Code Jeopardy

David T. Lewis
On Wed, May 04, 2016 at 02:02:43PM -0700, Eliot Miranda wrote:

> On Wed, May 4, 2016 at 5:37 AM, Bert Freudenberg <[hidden email]>
> wrote:
>
> >
> > > On 04.05.2016, at 13:32, Tobias Pape <[hidden email]> wrote:
> > >
> > > Hi all,
> > >
> > > without executing, what does the following expression result in?
> > >
> > > #(
> > > 25rFFs2
> > > 26rFFs2
> > > 27rFFs2
> > > 28rFFs2
> > > 29rFFs2
> > > 30rFFs2
> > > 31rFFs2
> > > 32rFFs2
> > > )
> > >
> > > Best regards
> > >       -Tobias
> >
> >
> > Interesting.
> >
> > 16rFFe4 used to be 16711680, now it???s 65508.
>
>
>
> >
> > VisualWorks suffers exactly the same issue:
>
> #(390 #s2 405 #s2 420 #s2 435 #s2 379264 419342 462150 507778)
>
> The only thing we can do is issue a warning, because otherwise we ban legal
> programs.  But we also need to disambiguate.  Should s or e in the
> penultimate positions force interpretation as scaled decimal or exponent,
> and hence force someone using a base >= 15 to use upper case?  Seems the
> only practical choice to me.  So we need tests and to modify printing.  At
> least we still print in upper case.

Given that most of us are not using base 32 arithmetic on a regular basis,
issuing a warning seems like a reasonable thing to do. In practice, the
problem would only arise when parsing numbers. Given a suitable warning,
the source of that data could presumably be edited in some way to avoid
the ambiguity.

A warning might be annoying, but it would be better than permitting numeric
data to be interpreted in unexpected ways.

Dave


>
> And BTW, I for one would hate having to enter hex constanrts in upper
> case.  Makes my VMMaker life much more difficult; all the disassemblers and
> debuggers I use print hex in lower case.
>
>
>
>
>
> > Try these:
> >
> > #(
> > 10r1e4
> > 11r1e4
> > 12r1e4
> > 13r1e4
> > 14r1e4
> > 15r1e4
> > 16r1e4
> > 17r1e4
> > 18r1e4
> > )
> >
>
> VW refuses to parse these (non-decimal integers cannot have exponents, and
> if one adds a decimal point, non-radix 10 numbers cannot contain a decimal
> point.
>
>
> > Maybe we need to raise an error for certain combinations? Better than a
> > surprise.

>


Reply | Threaded
Open this post in threaded view
|

Re: Code Jeopardy

David T. Lewis
On Wed, May 04, 2016 at 07:29:05PM -0400, David T. Lewis wrote:

> On Wed, May 04, 2016 at 02:02:43PM -0700, Eliot Miranda wrote:
> > On Wed, May 4, 2016 at 5:37 AM, Bert Freudenberg <[hidden email]>
> > wrote:
> >
> > >
> > > > On 04.05.2016, at 13:32, Tobias Pape <[hidden email]> wrote:
> > > >
> > > > Hi all,
> > > >
> > > > without executing, what does the following expression result in?
> > > >
> > > > #(
> > > > 25rFFs2
> > > > 26rFFs2
> > > > 27rFFs2
> > > > 28rFFs2
> > > > 29rFFs2
> > > > 30rFFs2
> > > > 31rFFs2
> > > > 32rFFs2
> > > > )
> > > >
> > > > Best regards
> > > >       -Tobias
> > >
> > >
> > > Interesting.
> > >
> > > 16rFFe4 used to be 16711680, now it???s 65508.
> >
> >
> >
> > >
> > > VisualWorks suffers exactly the same issue:
> >
> > #(390 #s2 405 #s2 420 #s2 435 #s2 379264 419342 462150 507778)
> >
> > The only thing we can do is issue a warning, because otherwise we ban legal
> > programs.  But we also need to disambiguate.  Should s or e in the
> > penultimate positions force interpretation as scaled decimal or exponent,
> > and hence force someone using a base >= 15 to use upper case?  Seems the
> > only practical choice to me.  So we need tests and to modify printing.  At
> > least we still print in upper case.
>
> Given that most of us are not using base 32 arithmetic on a regular basis,
> issuing a warning seems like a reasonable thing to do. In practice, the
> problem would only arise when parsing numbers. Given a suitable warning,
> the source of that data could presumably be edited in some way to avoid
> the ambiguity.
>
> A warning might be annoying, but it would be better than permitting numeric
> data to be interpreted in unexpected ways.
>

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 :-(

Dave


Reply | Threaded
Open this post in threaded view
|

Re: Code Jeopardy

Stéphane Rollandin
> 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


Reply | Threaded
Open this post in threaded view
|

Re: Code Jeopardy

Bert Freudenberg
On 06.05.2016, at 10:21, Stéphane Rollandin <[hidden email]> 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 -






smime.p7s (5K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Code Jeopardy

Eliot Miranda-2
Hi Bert, Hi All,

> On May 6, 2016, at 5:24 AM, Bert Freudenberg <[hidden email]> wrote:
>
>> On 06.05.2016, at 10:21, Stéphane Rollandin <[hidden email]> 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.

+1

>
> 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.

Please no.  It's convenient but a horrible wart on the side in an elegant syntax.
>
> I actually like the latter, the only problem would be that code using lower-case hex numbers would have to be rewritten.

How about trying to add code to the compiler's error handling to auto convert 0x form C hex into Smalltalk syntax?  0x0 gets parsed as 0 x 0, which is a syntax error, so once spotted, adding a bulk edit that does look for 0x[0-9A-Fa-f]+ shouldn't be too hard.

>
> - Bert -
>
>
>
>

Reply | Threaded
Open this post in threaded view
|

Re: Code Jeopardy

Nicolas Cellier


2016-05-06 17:01 GMT+02:00 Eliot Miranda <[hidden email]>:
Hi Bert, Hi All,

> On May 6, 2016, at 5:24 AM, Bert Freudenberg <[hidden email]> wrote:
>
>> On 06.05.2016, at 10:21, Stéphane Rollandin <[hidden email]> 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.

+1

>
> 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.

Please no.  It's convenient but a horrible wart on the side in an elegant syntax.
>
> I actually like the latter, the only problem would be that code using lower-case hex numbers would have to be rewritten.

How about trying to add code to the compiler's error handling to auto convert 0x form C hex into Smalltalk syntax?  0x0 gets parsed as 0 x 0, which is a syntax error, so once spotted, adding a bulk edit that does look for 0x[0-9A-Fa-f]+ shouldn't be too hard.


I'm not at all convinced by a warning, nor fond of 0x which is terribly limited
(we could allow 0x in specialized parser, maybe ExtendedParser but may be not in Smalltalk parser).

What would be much nicer is the possibility to clearly separate the exponent or scale specification.
For example something like 32rFF_s2 or 16r1.0_e1.
Underscore would sound a good candidate, unless we keep it for thousand separator 1_400_000?
# is another candidate, 16r1.0#e1

But it means changing Smalltalk syntax...

 
>
> - Bert -
>
>
>
>




Reply | Threaded
Open this post in threaded view
|

Re: Code Jeopardy

J. Vuletich (mail lists)
To disambiguate, we need two different syntaxes: One for uppercase  
digits with $e, $s etc suffixes, and one for caseless digits and no  
suffixes.

One of them might be the one we have now. We might keep it for case  
insensitive integers: 16rFFe2 = 16rFFE2 = 16rffe2 = 65506.

The other one could be use $q instead of $r: '16qFFe2' could mean  
'16rFF00'or 65280.

Or alternatively, acknowledge that the prefix '16r' is arbitrarily in  
decimal. This is something I never liked. A better way to say radix  
sixteen could be to express it in a single digit. So a decimal number  
could be 'Ar256', and 'GrFFE2' would be 65506 while 'GrFFe2' could be  
65280.

I prefer the latter, although it might need more explaining.

Regards,
Juan Vuletich

Quoting Nicolas Cellier <[hidden email]>:

> 2016-05-06 17:01 GMT+02:00 Eliot Miranda <[hidden email]>:
>
>> Hi Bert, Hi All,
>>
>> > On May 6, 2016, at 5:24 AM, Bert Freudenberg <[hidden email]>
>> wrote:
>> >
>> >> On 06.05.2016, at 10:21, Stéphane Rollandin <[hidden email]>
>> 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.
>>
>> +1
>>
>> >
>> > 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.
>>
>> Please no.  It's convenient but a horrible wart on the side in an elegant
>> syntax.
>> >
>> > I actually like the latter, the only problem would be that code using
>> lower-case hex numbers would have to be rewritten.
>>
>> How about trying to add code to the compiler's error handling to auto
>> convert 0x form C hex into Smalltalk syntax?  0x0 gets parsed as 0 x 0,
>> which is a syntax error, so once spotted, adding a bulk edit that does look
>> for 0x[0-9A-Fa-f]+ shouldn't be too hard.
>>
>>
> I'm not at all convinced by a warning, nor fond of 0x which is terribly
> limited
> (we could allow 0x in specialized parser, maybe ExtendedParser but may be
> not in Smalltalk parser).
>
> What would be much nicer is the possibility to clearly separate the
> exponent or scale specification.
> For example something like 32rFF_s2 or 16r1.0_e1.
> Underscore would sound a good candidate, unless we keep it for thousand
> separator 1_400_000?
> # is another candidate, 16r1.0#e1
>
> But it means changing Smalltalk syntax...
>
>
>
>> >
>> > - Bert -
>> >
>> >
>> >
>> >
>>
>>




Reply | Threaded
Open this post in threaded view
|

Re: Code Jeopardy

Stéphane Rollandin
In reply to this post by Bert Freudenberg
>> {
>> 25rFFs2.
>> 26rFFs2.
>> 27rFFs2.
>> 28rFFs2.
>> 29rFFs2.
>> 30rFFs2.
>> 31rFFs2.
>> 32rFFs2
>> }
>>
>> instead.
>>
>> Stef
>
> Writing it that way does not make any difference.

That is a problem, then :)

Stef