Skip to content
Tcl Source Code View Ticket
Login

View Ticket

set a variable in namespace set global variable

Closed / Invalid1280497fffffffffffffffffffffffffffffffffCreated 21 years agoUpdated 21 years ago
Descriptionplain2005-09-02 10:24:03
GNU/Linux 2.6.8-24.17-default i686 athlon 

patchlevel -- 8.4.11


% set data 0
0
% namespace eval ::ini { set data 1 }
1
% puts $data
1
% puts $::ini::data
can't read "::ini::data": no such variable


[email protected]
dkfplain2005-09-02 19:15:46
Logged In: YES 
user_id=79902

This is, believe it or not, how variable resolution is
supposed to work, i.e. it is designed that way. Stupid,
isn't it?

Altering this would be an RFE, not a bugfix...
msofer Closed ticket [1280497fff]. [History diff]2005-09-02 20:46:06
msoferplain2005-09-02 20:46:07
Logged In: YES 
user_id=148712

Works as documented, see the [namespace] manual page
(especially the section NAME RESOLUTION):
http://www.tcl.tk/man/tcl8.4/TclCmd/namespace.htm#M22

FWIW, we all seem to agree that this rule for variable name
resolution is crazy. Changing this is very delicate, for
backwards compatibility reasons. Let's hope it happens for
Tcl9.0

The way out is to "declare" namespace variables using the
[variable] command.

For some other related pitfalls, see bug #959052.
Log in (anonymous is fine) to add a comment.