Skip to content
Tcl Source Code View Ticket
Login

View Ticket

namespace eval not finding global variables

Closed / Works For Me2634f337a79d00e4a5c8d3d81e3cbd446b297549Created 3 years agoUpdated 3 years ago
Descriptionplain2023-12-05 00:36:40
The manual for tcl9.0 has not changed for namespace name resolution and so I will assume that the example should still work. It does work in 8.6, the below is in 9.0b1

% proc printTrace {args} {puts {*}$args} ;# my def to make this work

% set traceLevel 0
0
% namespace eval Debug {
     printTrace $traceLevel
 }
can't read "traceLevel": no such variable

It does, however, find the procedure printTrace.

It is supposed to look first in the Debug namespace, but not finding it there, it should eventually find it in the global namespace.

One place this occurs is in BWidgets, the file  dropsite.tcl does a test,

namespace eval DropSite {
...snip...
    if { $tcl_platform(platform) == "unix" } {

which being inside a namespace eval did not find tcl_platform. I had to fix it by changing to $::tcl_platform
anonymousplain2023-12-05 08:32:09
Ahhhh, I found the release notes, where it documents this NEW behavior.

However, the manual, (a recent core mailing list)

 https://www.tcl3d.org/bawt/download/Preview/Tcl9/TclTkManual/index.html

There the manual has not been updated and still describes the 8.6 behavior, not the 9.0.
oehharwiki2023-12-05 09:45:29

Great, that you have found it. Here is the draft of the official migration guide: https://core.tcl-lang.org/tcl/wiki?name=Migrating+scripts+to+Tcl+9

Help welcome ! Harald

Log in (anonymous is fine) to add a comment.