Fun with Number readFrom: What should we do ?
ncellier@ifrance.com
ncellier at ifrance.com
Thu Apr 27 14:06:12 UTC 2006
I agree, my prop was low level, yours is higher level (extensible)
Nicolas
Diego Fernandez:
> My proposition is:
>
> Number>>readFrom: aStringOrStream
> ^self readFrom: aStringOrStream ifFail: [^self error: 'cannot read a
> number']
>
> If nil is what you want, you will have to write:
> value := Number readFrom: aStream ifFail: [nil].
> A little longer than your proposition:
> value := Number readfrom: aStream.
The mine is:
Number>>readFrom: aStringOrStream
^NumberParser new parse: aStringOrStream
NumberParser>>parse: aStringOrStream
"on failure"
NumberParsingException signal
"or just ParseException"
I think that #readFrom: must be an extension of Number.
So if you want more control of the parsing you can configure an
instance of NumberParser.
(may be you can have a FortranNumberParser :)).
________________________________________________________________________
iFRANCE, exprimez-vous !
http://web.ifrance.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20060427/f10c11c2/attachment.htm
More information about the Squeak-dev
mailing list
|