Squeak 3.9: using SqNumberParser in Number>>readFrom:

Damien Cassou damien.cassou at gmail.com
Sat Mar 24 17:23:50 UTC 2007


Hi Matthias,

2007/3/24, Matthias Berth <matthias.berth at googlemail.com>:
> Hi,
>
> I have found the discussion from last year:
>
>   Fun with Number readFrom: What should we do ?
>   http://lists.squeakfoundation.org/pipermail/squeak-dev/2006-April/103137.html
>
> Basically, the problem was that Number>>readFrom: will produce 0 where
> it should raise an error (e.g. when the input is letters only). There
> is a fix at
>
>   http://bugs.squeak.org/view.php?id=3512
>
> i.e. a new class SqNumberParser does the right thing. The bug was
> closed, but the problem still remains: while SqNumberParser is in the
> Squeak 3.9 image,  Number>>readFrom is still the old method.
>
> Do you have any pointers to the next step, i.e. changing the code in
> classes Number, Integer (and wherever else)?
>
> I have encountered this problem when using Magritte: when I use a
> MANumberDescription for a field, there still is no check if the user
> enters a number. Validation fails because the from field value is
> interpreted using Number>>readFrom, so it produces 0 for inputs like
> "xyz".

Nicollas can tell you more about SqNumberParser.

But with Magritte, I think you can replace the way it translates the
string to a number. What I would start with if I were you: implement
#visitNumberDescription: in MAStringReader. Look at
MAStringReader>>visitElementDescription: to see the current default
implementation.


-- 
Damien Cassou



More information about the Squeak-dev mailing list