Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 6469b56e58893b4ff39a1b3421ba3a1a34e3da9a
Ticket: 1251123fffffffffffffffffffffffffffffffff
Variable resolution behaviour and documentation
User & Date: oox on 2005-08-03 15:51:49
Changes

  1. assignee changed to: "msofer"
  2. cmimetype changed to: "text/plain"
  3. comment changed to:
    Consider the following: 
    
    (bin) 1 % namespace eval ::N {set bar 2} 
    2 
    (bin) 2 % puts $bar 
    can't read "bar": no such variable 
    (bin) 3 % puts $::N::bar 
    2 
    (bin) 4 % set foo 1 
    1 
    (bin) 5 % puts $foo 
    1 
    (bin) 6 % namespace eval ::N {set foo 2} 
    2 
    (bin) 7 % puts $foo 
    2 
    (bin) 8 % puts $::N::foo 
    can't read "::N::foo": no such variable 
    
    I would expect line 6 to create ::N::foo, in the same way 
    that line 1 created ::N::bar, but Tcl notices that ::foo 
    exists, and somehow resolves to it. The NAME 
    RESOLUTION section of the [namespace] manual page 
    says that for unqualified names the following 
    applies: "Command and variable names are always 
    resolved by looking first in the current namespace, and 
    then in the global namespace". This applies 'correctly' 
    to variable *access*, but in a funny way to variable 
    *creation*. 
    
    What is worse, command creation behaves differently: 
    invoking [proc] with an unqualified procedure name 
    within a namespace creates the procedure in that 
    namespace irrespectively on whether or not an equally 
    named procedure already exists in the global 
    namespace. 
    
    I understand that modyifing variable resolution rules is 
    something to be avoided. What I propose is adding a 
    sentence to the NAME RESOLUTION section of the 
    [namespace] manual page above describing this 
    observed behaviour.
    
  4. foundin changed to: "None"
  5. priority changed to: "5 Medium"
  6. resolution changed to: "None"
  7. status changed to: "Open"
  8. submitter changed to: "oox"
  9. subsystem changed to: "21. [namespace]"
  10. title changed to: "Variable resolution behaviour and documentation"
  11. type changed to: "Bug"