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 2025-09-04 16:16:22 and 2026-07-30 10:24:11

︙
133
134
135
136
137
138
139
140

141
142
143



144














145
146
147
148
149
150
151
133
134
135
136
137
138
139

140
141
142

143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167







-
+


-
+
+
+

+
+
+
+
+
+
+
+
+
+
+
+
+
+








Q - has the behavior of `global` changed within namespaces?

The behavior of the `global` command within namespaces has not changed. The command has no effect when used outside the context of a proc or apply body. Using `global` inside a namespace eval block does nothing. Variable names passed to the global command are still resolved relative to the global namespace, as they have always been. So, using `global ns::var` (inside a proc or apply body) will create a local variable var that is linked to the namespace variable ::ns::var.

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

## Changes in parsing of variable names
## Changes in parsing of variable names and array index names

When parsing braced variable references of the form `${..}`, in 8.6 the first `}` always terminated the variable name. In 9.0, any nested `{` are counted and the variable name is terminated by the `}` matching the opening `{`.
A similar change also applies to parsing of array element names enclosed in `()`.

Referenced array element names (`$a(name)`) do not end verbatim until the closing `)` any more.
Any special character like double quotes, backslash, parenthesis and braces shall be properly escaped.

In the following example, the array index name consists of a double quote, a "b" and another double quote:
```
% set a("b") x
x
% puts $a(\"b\")
```
In 8.6, the escaping of the double quotes in the reference were not required but accepted.

For symetry and readability, the index in the set command may also be quoted:
```
% set a(\"b\") x
```

The reason for this is also symetry to the `expr` command.
See [TIP 465](https://core.tcl-lang.org/tips/doc/trunk/tip/465.md).

## Arguments to `load` are Unicode-aware and case sensitive

In Tcl 8, the second argument to the `load` command which specifies
the initialization function was case-insensitive. This is inconsistent
with the rules for package names which are case-sensitive. In Tcl 9,
︙