Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2004-05-25
21:29 • Closed ticket [960154ffff]: global.n, upvar.n: qualified varNames? plus 3 ot... artifact: 02b2bb1fc6 user: msofer
14:10 • New ticket [960154ffff]. artifact: 497c104825 user: msofer

global.n, upvar.n: qualified varNames?

Closed / Duplicate960154ffffffffffffffffffffffffffffffffffCreated 23 years agoUpdated 23 years ago
Descriptionplain2004-05-25 14:10:08
The manual pages for global and upvar commands do not
explain the behaviour when the variable names contain
namespace qualifiers.

This is not so bad for upvar, as the behaviour is quite
intuitive. Not the same for global ...

One possibility is to explain global's behaviour, and
show that it could be defined as
  
   proc global args {
       if {[info level] < 2} {
           return
       }
       set cmdName [namespace tail [lindex [info level
-1] 0]]
       if {[info procs $cmdName] eq {}} {
           return 
       }
       set cmd [list upvar 0]
       foreach var $args {
           lappend cmd ::$var [namespace tail $var]
       }
       uplevel 1 $cmd
       return
    }
msofer Closed ticket [960154ffff]. [History diff]2004-05-25 21:29:01
Log in (anonymous is fine) to add a comment.