Skip to content
Tcl Source Code Changes To Migrating scripts to Tcl 9
Login

Changes To Migrating scripts to Tcl 9

Changes to "Migrating scripts to Tcl 9" between 2023-11-01 21:08:20 and 2023-11-06 16:37:58

︙
45
46
47
48
49
50
51
52

53





54


















55
56
57
58
59
60
61
45
46
47
48
49
50
51

52
53
54
55
56
57
58

59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83







-
+

+
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+







languages but run-time values as well. For example, if the `string is
integer` command is used to validate user input as integers, it will
allow underscores to be entered. If this is not desired, such validation
needs to be changed to use `scan` or regexps.

See [TIP 551](https://core.tcl-lang.org/tips/doc/trunk/tip/551.md).

## Changes in integer handling
## Changes in integer classification and handling

The command `string is integer` now accepts integers of any size and is not limited to 32 bit values. Analogously, the `int()` function will no longer truncate integer values to a 32-bit range. The following illustrates the difference.

In Tcl 8,

```
TBD - int() does not truncate, string is integer same as entier etc.
% string is integer 0x100000001
0
% expr {int(0x100000001)}
1
```

In Tcl 9,

```
% string is integer 0x100000001
1
% expr {int(0x100000001)}
4294967297
```

Thus `string is integer` should not be used for range validation; use explicit range checks. Likewise, `int()` cannot be used for truncation; use explicit masking of high order bits.

Further, the commands `string is entier` and `string is wide` and functions `entier()` and `wide()` are deprecated. Again, use explicit range checks and masking instead.

See [TIP 514](https://core.tcl-lang.org/tips/doc/trunk/tip/514.md).

## Change in variable name resolution

In Tcl 8 variable names that are not absolute, are resolved by looking first in the current namespace, and then in the global namespace. In Tcl 9 such variables are always interpreted as relative to the current namespace.

︙