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
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 Pharo-project@lists.gforge.inria.fr http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
2009/3/20 Göran Krampe goran@krampe.se:
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.
2009/3/20 Damien Cassou damien.cassou@gmail.com
2009/3/20 Göran Krampe goran@krampe.se:
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
On Fri, Mar 20, 2009 at 10:52 PM, Nicolas Cellier nicolas.cellier.aka.nice@gmail.com 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
Hi again
2009/3/20 Göran Krampe goran@krampe.se
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.htm... 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 :)
Yes remove it, it was used once in early days, before I correct conversions Integer>>asFloat Fraction>>asFloat (all started from here http://lists.squeakfoundation.org/pipermail/squeak-dev/2006-April/102465.htm... )
There is more at: http://bugs.squeak.org/view.php?id=7169 http://bugs.squeak.org/view.php?id=6779 http://bugs.squeak.org/view.php?id=7174 http://bugs.squeak.org/view.php?id=6976 http://bugs.squeak.org/view.php?id=6982
regards, Göran
And still, one thing lacks, a proper NumberParserException...
Nicolas
squeak-dev@lists.squeakfoundation.org