apnadkarni / tcl9-migrate

Utilities to help migration from Tcl 8 to Tcl 9
Other
6 stars 1 forks source link

string is int reporting / general help / questions #3

Open andreas-kupries opened 3 months ago

andreas-kupries commented 3 months ago

help currently says

### [STRINGISINT]

Unlike Tcl 8, the `string is integer` command will accept integers
that do not fit in 32-bits. Furthermore, the command will accept and
ignore `_` as a separator within numeric strings. Therefore any use
of the command should be checked that it is not used as a 32-bit range
check or for validation where the string should be strictly numeric.

What commands should be used for validating strictly numeric ?

Alternatively, what commands are recommended for conversion from not-strictly numeric values like 1_234_2 to the embedded numeric, i.e. 12342 ?

On the general side, links to the relevant TIP(s) would be nice to have.

For STRINGISINT it looks to be 551

Unfortunately does not say if scan would accept the extended number. Will have to check/experiment. From the example I might be able use set x [expr $x] to get to the strict value.

The relevant code which triggered the issue is

    if {[string is integer -strict $value]} {
        if {($min eq {}) || ($value < $min)} { set min $value }
        if {($max eq {}) || ($value > $max)} { set max $value }
[...]

and thinking about what parts of the core are now able to handle the non-strict numbers.