toInt

Pieter Koopman pieter@cs.kun.nl
Thu, 17 Dec 1998 09:40:56 +0100


At 06:17 PM 12/16/98 +0100, Rolf-Thomas Happe wrote:
>The current implementation (*) of toInt doesn't interpret its input
>string in the way Clean treats integer literals in the program text
>(and it returns 0 on failure).  E.g.
>
>   ("+12", +12, toInt "+12",
>    "012", 012, toInt "012",
>    "0x12", 0x12, toInt "0x12",=20
>    "knorpel", toInt "knorpel")
>
>evaluates to
>
>   ("+12",12,12,
>    "012",10,12,
>    "0x12",18,0,
>    "knorpel",0).
>
>Since the name 'toInt` doesn't tell me that, a few words of spec (in
>StdString.dcl or elsewhere) would be nice.

The reason that toInt handles errors in the input the way it does is
determined by the type of the class toInt. The only other option to handle
errors in the conversion is an abort=85
We plan to incorporate parser combinators in a future release of the
environment. They will be capable to handle errors much better.
The hexadecimal notation for integers and the proper handling of leading
zeros should be incorporated in the next release.

Pieter Koopman