Menu

#1655 [namespace which -var] fails for ary(i)

obsolete: 8.4a3
open
6
2009-05-01
2001-10-17
No

[namespace which -variable ary(i)] returns a null
string even when ary(i) exists! This is a major pain
when trying to get fully scoped variable names to give
to widgets. Here is a script snippet that shows the
eror:

Discussion

  • Bruce Hartweg

    Bruce Hartweg - 2001-10-17

    Logged In: YES
    user_id=338658

    Got submitted to quick...
    namespace eval a {
    variable ary
    set ary(i) v
    puts "1 - [namespace which -variable ary]"
    set x ary
    set y ary(i)
    puts "2 - [namespace which -variable $x]"
    puts "3 - [namespace which -variable $y]"
    }

     
  • Bruce Hartweg

    Bruce Hartweg - 2001-10-17
    • labels: --> 21. [namespace]
     
  • Don Porter

    Don Porter - 2002-01-15
    • assigned_to: nobody --> msofer
     
  • miguel sofer

    miguel sofer - 2002-08-07

    Logged In: YES
    user_id=148712

    (1) Sorry, this bug somehow flew under my horizon :(

    (2) It's not so clear to me what the correct fix would be:
    what should happen if the array itself exists, but the array
    element does not? In your script, what is the expected
    result of adding a line
    puts "4 - [namespace which -variable ary(k)]"
    According to the man page, the return should be "" - is this
    what you're expecting?

    (3) Depending on the answer to (2), a workaround involving
    [info exists] may be the solution for now.

     
  • Don Porter

    Don Porter - 2003-11-13
    • milestone: --> obsolete: 8.4a3
     
  • miguel sofer

    miguel sofer - 2006-10-01

    Logged In: YES
    user_id=148712

    This cannot be fixed at reasonable cost without changing the
    Var struct: an array element does not know it's containing
    array, even though it knows its hashtable.

    This will probably not happen until Tcl9. Leaving the bug
    open to fix at that time.

     
  • miguel sofer

    miguel sofer - 2009-05-01
    • priority: 5 --> 6