|
2006-11-14
| ||
| 10:20 | • Closed ticket [604226ffff]: variable should always create a link plus 6 ot... artifact: f7c1019e2f user: sf-robot | |
|
2006-10-31
| ||
| 02:36 | • Pending ticket [604226ffff]. artifact: 5c959e450c user: msofer | |
|
2006-10-03
| ||
| 05:56 | • Ticket [604226ffff]: 4 changes artifact: d6949d8c04 user: msofer | |
|
2006-09-30
| ||
| 00:46 | • Ticket [604226ffff]: 1 change artifact: 0178ce22a5 user: msofer | |
|
2004-03-30
| ||
| 15:30 | • Ticket [604226ffff]: 2 changes artifact: 662a652196 user: dkf | |
|
2004-03-29
| ||
| 23:29 | • Ticket [604226ffff]: 6 changes artifact: c0cdf80b8a user: msofer | |
| 23:29 | • Ticket [604226ffff]: 3 changes artifact: 3869f132e7 user: msofer | |
| 23:11 | • Ticket [604226ffff]: 1 change artifact: 6c57049cb8 user: dgp | |
| 23:10 | • Ticket [604226ffff]: 4 changes artifact: b142fdb6a8 user: dgp | |
|
2004-03-28
| ||
| 07:20 | • Ticket [604226ffff]: 6 changes artifact: dcf13d9214 user: msofer | |
|
2002-09-04
| ||
| 06:03 | • Ticket [604226ffff]: 4 changes artifact: d4a9836dd2 user: dgp | |
|
2002-09-03
| ||
| 22:31 | • New ticket [604226ffff]. artifact: ae138cf721 user: dgp | |
[variable] should always create a link
Closed / Rejected604226ffffffffffffffffffffffffffffffffffCreated 24 years agoUpdated 20 years ago
Descriptionplain2002-09-03 22:31:37
% namespace eval a variable x % namespace eval b variable ::a::x % set a::x 1 1 % info exists b::x 0
dgpplain2002-09-04 06:03:54
Logged In: YES
user_id=80530
If this is not a bug, it's definitely a place to
clarify the docs. Related behavior:
% namespace eval a variable x 1
% namespace eval b variable ::a::x
% puts $b::x
can't read "b::x": no such variable
% namespace eval b {
variable ::a::x
puts $x
}
can't read "x": no such variable
% proc b::foo {} {
variable ::a::x
puts $x
}
% b::foo
1
Different behavior of [variable] within
a proc compared to within a [namespace eval]
needs either correction or more explicit documentation.
msoferplain2004-03-28 07:20:57
Logged In: YES user_id=148712 Don: care to re-read variable.n? That is actually the documented behaviour, except that the docs are not too explicit about what happens with varnames with :: within procs ... The problem is: you (and I, and maybe everybody else ...) expect 'variable' to create a local linked variable even when not in a proc. But that is not what is promised, ie: it is not true that variable ::a::x is equivalent to upvar 0 ::a::x x Apparently 'variable' was born to correct for the weird lookup rules we have? So: what do we do? RFE/TIP? Leave as is?
dgpplain2004-03-29 23:10:49
Logged In: YES user_id=80530 I tend to think this is a mis-feature. I accept I may be missing something important, yet subtle. I'd like to see a TIP propsing the addition of setting up namespace -> namespace variable links by [variable] when not within a proc. If in fact, that is a bad idea, then some of the examples in this report could be incorporated into variable.n to more explicitly demonstrate the difference.
dgp Ticket [604226ffff]: 1 change
[History diff]2004-03-29 23:11:21
msofer Ticket [604226ffff]: 3 changes
[History diff]2004-03-29 23:29:20
msoferplain2004-03-29 23:29:21
Logged In: YES user_id=148712 Reclassifying then as RFE. The request is that, whenever [variable] addresses a namespace variable in a different namespace, it also creates a local link. In code, that whenever $name is a qualified variable name, variable $name $val be equivalent to set lname [namespace tail $name] upvar 0 $name $lname set $lname $val This would require a TIP.
dkf Ticket [604226ffff]: 2 changes
[History diff]2004-03-30 15:30:44
msofer Ticket [604226ffff]: 1 change
[History diff]2006-09-30 00:46:41
msoferplain2006-10-03 05:56:53
Logged In: YES user_id=148712 Uh ... not nice, [variable] is not even really a noop: % namespace eval a variable x % namespace eval b variable ::a::x 1 % set a::x 1 % set b::x can't read "b::x": no such variable
msoferplain2006-10-31 02:36:43
Logged In: YES
user_id=148712
We isunderstood the purpose and/or docs of [variable].
Looking at namespace-old.test, I see that the usage there
(and, from the comments, possibly an idiom in itcl) really
requires the current behaviour outside of proc bodies.
Consider test namespace-old.6.16 - to reduce headaches,
notice that
- there are no linked variables there
- $trigger has been last defined in test 6.12, and is
{set test_ns_cache_var}
- $trigger2 has been last defined in test 6.15 and is
{set test_ns_cache2::test_ns_cache_var}
The test body is
variable test_ns_cache1::test_ns_cache2::test_ns_cache_var
"blah"
list [namespace eval test_ns_cache1 $trigger2] \
[namespace eval test_ns_cache1::test_ns_cache2 $trigger]
Here [variable] is being used to set the value of the variable
::test_ns_cache1::test_ns_cache2::test_ns_cache_var
from the global space, but without a fully qualified name
(why?). If a variable ::test_ns_cache_var were created to
point to it, all manner of nastyness could ensue: a new
GLOBAL variable that may break whatever code relies on the
second lookup path, and wasted resources as the programmer
never expected that new variable to be created.
In order to link variables, use [upvar] or [namespace upvar].
sf-robotplain2006-11-14 10:20:11
Logged In: YES user_id=1312539 This Tracker item was closed automatically by the system. It was previously set to a Pending status, and the original submitter did not respond within 14 days (the time period specified by the administrator of this Tracker).
Log in (anonymous is fine) to add a comment.