[squeak-dev] Re: The Trunk: Multilingual-ar.87.mcz

Nicolas Cellier nicolas.cellier.aka.nice at gmail.com
Fri Feb 12 10:34:11 UTC 2010


2010/2/12 John M McIntosh <johnmci at smalltalkconsulting.com>:
> Also see
> http://code.google.com/p/pharo/issues/detail?id=1258
>
> '.1' asNumber  toss an error in  Pharo 1.1 11043
> and
>
> '1.0e+2'  asNumber
> returns 1.0
>

If it's a matter of traditional Smalltalk syntax, we could check
result with these Smalltalks:
- gst
- VW
- Dolphin
- vast
- stx
- ...

If it's a matter of extending the syntax, we could also try current
squeak version for:
'+1' asNumber.
'1,964' asNumber.

Where to stop ?
We have to write some EBNF rules and/or simply provide a few TestCase
documenting the expectations (say with unit TestCase).

In Pharo, I rejected undocumented non-Smalltalk syntax.
The reason is that (Number>>readFrom:) is used by Parser, and 1.e2  or
.1e2 are ambiguous in Smalltalk syntax.

Stupid example:
| e2 y |
e2:=1.
y:=1.e2 storeOn: Transcript.Transcript endEntry.
^y

According to st-80 and documented Squeak EBNF syntax, it should print
1, not 100.

This does not need to be written on stone, we can evolve Smalltalk
syntax, or we can easily dissociate String>>asNumber from Parser usage
with two subclasses of NumberParser...
Some applications would also prefer a localized decimal separator for example...
But this has to be decided on rational bases, not just by addition of
incomplete undocumented hacks in readFrom: for specific application
usage.

Nicolas

> yet other I think more knowledgeable people say
> http://www.wolframalpha.com/input/?i=1.0e%2B2
> 100
>
> I'd just say any expectations of converting a string to a number in most flavours of Squeak should be viewed with suspicion.
>
> On 2010-02-12, at 12:44 AM, Andreas Raab wrote:
>
>> Nicolas Cellier wrote:
>>> This of course fail with Number>>readFrom:
>>> You can also simply try
>>> 3r1.1e55 - 3r11.0e54
>>> and the SqNumberParser form...
>>> (SqNumberParser parse: '3r1.1e55') - (SqNumberParser parse: '3r11.0e54')
>>> Maybe it's time to push the readFrom: changes i already pushed in Pharo...
>>
>> Go for it. You're the best expert we have in this area, and I trust your  judgment.
>>
>> Cheers,
>>  - Andreas
>>
>
> --
> ===========================================================================
> John M. McIntosh <johnmci at smalltalkconsulting.com>   Twitter:  squeaker68882
> Corporate Smalltalk Consulting Ltd.  http://www.smalltalkconsulting.com
> ===========================================================================
>
>
>
>
>
>



More information about the Squeak-dev mailing list