[squeak-dev] SqNumberParser!

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

[squeak-dev] SqNumberParser!

Göran Krampe
Howdy folks!

In working on Tirade I stumbled upon SqNumberParser and its history:

http://bugs.squeak.org/view.php?id=3512

...it was added to the image in 3.9 but not hooked into Scanner -
Scanned still uses Number class>>readFrom:.

Now... In Tirade I can use whichever - but using SqNumberParser makes it
more correct, and quite faster - although "less portable" since I would
depend on it. I will now make Tirade use SqNumberParser *if present* in
the image, otherwise fall back on Number class>>readFrom:. This opens up
some slight potential incompatibility issues, but whatever.

Question: Is there anything stopping 3.9+ including Pharo to start using
SqNumberParser from Scanner>>xDigit?

And oh, the class name is not so good IMHO, why the Sq prefix?

And yeah, class var not used in SqNumberParser: BelllerophonBase10 :)

regards, Göran


Reply | Threaded
Open this post in threaded view
|

[squeak-dev] Re: [Pharo-project] SqNumberParser!

Stéphane Ducasse
if nicolas do it we will integrate it I imagine :)

On Mar 20, 2009, at 11:22 AM, Göran Krampe wrote:

> Howdy folks!
>
> In working on Tirade I stumbled upon SqNumberParser and its history:
>
> http://bugs.squeak.org/view.php?id=3512
>
> ...it was added to the image in 3.9 but not hooked into Scanner -
> Scanned still uses Number class>>readFrom:.
>
> Now... In Tirade I can use whichever - but using SqNumberParser  
> makes it
> more correct, and quite faster - although "less portable" since I  
> would
> depend on it. I will now make Tirade use SqNumberParser *if present*  
> in
> the image, otherwise fall back on Number class>>readFrom:. This  
> opens up
> some slight potential incompatibility issues, but whatever.
>
> Question: Is there anything stopping 3.9+ including Pharo to start  
> using
> SqNumberParser from Scanner>>xDigit?
>
> And oh, the class name is not so good IMHO, why the Sq prefix?
>
> And yeah, class var not used in SqNumberParser: BelllerophonBase10 :)
>
> regards, Göran
>
>
> _______________________________________________
> Pharo-project mailing list
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>


Reply | Threaded
Open this post in threaded view
|

Re: [squeak-dev] SqNumberParser!

Damien Cassou-3
In reply to this post by Göran Krampe
2009/3/20 Göran Krampe <[hidden email]>:
>
> Question: Is there anything stopping 3.9+ including Pharo to start using
> SqNumberParser from Scanner>>xDigit?

IIRC the only problem is with parsing non numbers like 'abc'.
#readFrom: returns 0 whereas SqNumberParser throws an exception.

--
Damien Cassou
http://damiencassou.seasidehosting.st

Reply | Threaded
Open this post in threaded view
|

Re: [squeak-dev] SqNumberParser!

Nicolas Cellier
In reply to this post by Göran Krampe
Hi again

2009/3/20 Göran Krampe <[hidden email]>
Howdy folks!

In working on Tirade I stumbled upon SqNumberParser and its history:

http://bugs.squeak.org/view.php?id=3512

...it was added to the image in 3.9 but not hooked into Scanner - Scanned still uses Number class>>readFrom:.

Now... In Tirade I can use whichever - but using SqNumberParser makes it more correct, and quite faster - although "less portable" since I would depend on it. I will now make Tirade use SqNumberParser *if present* in the image, otherwise fall back on Number class>>readFrom:. This opens up some slight potential incompatibility issues, but whatever.

Question: Is there anything stopping 3.9+ including Pharo to start using SqNumberParser from Scanner>>xDigit?

And oh, the class name is not so good IMHO, why the Sq prefix?

The history starts here http://lists.squeakfoundation.org/pipermail/squeak-dev/2006-April/103137.html
I think Diego Fernandez first proposed to use a class for parsing Numbers,
but then Francisco Garau prepended a Sq (to emphasize Squeak peculiarities?) and the name remained as is...
I am also equipped with a FORTRAN, a Dolphin and a VW Number parser, and guess what ? Smalltalk syntax vary...
...But I agree, Squeak Academy should discuss new names entering in the Smalltalk dictionary ;)


And yeah, class var not used in SqNumberParser: BelllerophonBase10 :)


regards, Göran


And still, one thing lacks, a proper NumberParserException...

Nicolas



Reply | Threaded
Open this post in threaded view
|

Re: [squeak-dev] SqNumberParser!

Nicolas Cellier
In reply to this post by Damien Cassou-3

2009/3/20 Damien Cassou <[hidden email]>
2009/3/20 Göran Krampe <[hidden email]>:
>
> Question: Is there anything stopping 3.9+ including Pharo to start using
> SqNumberParser from Scanner>>xDigit?

IIRC the only problem is with parsing non numbers like 'abc'.
#readFrom: returns 0 whereas SqNumberParser throws an exception.

Sure, but if compatibilty counts, it would be very easy to implement
Number class>>readFrom: aStream
    ^SqNumberParser: parse: aStream ifFail: [^0]

Apart a few weird edge cases, it would be roughly the same...
... just more exact (round to nearest Float) and faster.


--
Damien Cassou
http://damiencassou.seasidehosting.st




Reply | Threaded
Open this post in threaded view
|

Re: [squeak-dev] SqNumberParser!

Damien Cassou-3
On Fri, Mar 20, 2009 at 10:52 PM, Nicolas Cellier
<[hidden email]> wrote:
> Sure, but if compatibilty counts, it would be very easy to implement
> Number class>>readFrom: aStream
>     ^SqNumberParser: parse: aStream ifFail: [^0]
>
> Apart a few weird edge cases, it would be roughly the same...
> ... just more exact (round to nearest Float) and faster.

http://code.google.com/p/pharo/issues/detail?id=681

--
Damien Cassou
http://damiencassou.seasidehosting.st