Overview
| Artifact ID: | 6469b56e58893b4ff39a1b3421ba3a1a34e3da9a |
|---|---|
| Ticket: | 1251123fffffffffffffffffffffffffffffffff
Variable resolution behaviour and documentation |
| User & Date: | oox on 2005-08-03 15:51:49 |
Changes
- assignee changed to: "msofer"
- cmimetype changed to: "text/plain"
- 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. - foundin changed to: "None"
- priority changed to: "5 Medium"
- resolution changed to: "None"
- status changed to: "Open"
- submitter changed to: "oox"
- subsystem changed to: "21. [namespace]"
- title changed to: "Variable resolution behaviour and documentation"
- type changed to: "Bug"