Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: bd6cab1a21fddaa2472c2b5a3aa4f3d5c08d2e5a
Ticket: 959786ffffffffffffffffffffffffffffffffff
bug in varName resolution
User & Date: msofer on 2006-10-02 07:44:39
Changes

  1. icomment:
    Logged In: YES 
    user_id=148712
    
    Note that it is "easy" to fix the code to keep the current
    way it works: just replace 'foo::name' with '::foo::name'
    everywhere. I do understand that "everywhere" could be lots
    of places, not minimising the work involved.
    
    Another (better) solution may be to do something like
    
    if {[info command variable] == {}} {
        proc nsvars {args} {
    set ns [lindex $args 0]
    set globals {}
    set upvars  {}
    foreach var [lrange $args 1 end] {
        set g $ns::$var
        lappend globals $g
        lappend upvars $g $var
    }
    uplevel 1 [list eval global $globals]
    uplevel 1 [eval eval upvar 0 $upvars]
        }
    } else {
        set ns [lindex $args 0]
        set all {}
        foreach var [lrange $args 1 end] {
    lappend upvars $var $var
        }
        uplevel 1 [list namespace upvar $ns {expand}$upvars]
    }
    
    namespace eval foo {}
    proc foo::bar {} {
        nsvars foo name1 name2
        set name1  1
        set name2 2
    }
    
    
    
    
  2. login: "msofer"
  3. mimetype: "text/plain"
  4. username: "msofer"