Overview
| Artifact ID: | 14386efd0b1b6a22f9507aec792659dfb68ebcda |
|---|---|
| Ticket: | fbc88fb645c5b2f47f16cd0e167ef47de081f212
[variable] doesn't follow variable resolution rules |
| User & Date: | sebres on 2017-05-31 16:09:08 |
Changes
- icomment:
<blockquote>> If [variable] resolves varnames differently from $-substitution </blockquote> I don't think so... Following: <pre><code> set ::a "::a (of global)"; namespace eval ::a {set a "[namespace current]::a"} set cnt [namespace eval ::foo { namespace eval a {set a "[namespace current]::a"} set a "[namespace current]::a" proc init {} { set i 0 foreach {vmap rmap} { a ::foo::a a::a ::foo::a::a ::a ::a ::a::a ::a::a ::foo::a ::foo::a ::foo::a::a ::foo::a::a } { incr i set args [list [list i $i] [list vmap $vmap] [list rmap $rmap]] proc test$i $args { variable $vmap set vexp {"$a" eq "[set $rmap]"} puts -nonewline [format "%d: %15s is %-15s == " $i $vmap $rmap] puts [format " %5s == {%s eq %-15s} -- {%s}" [if $vexp {set _ OK} else {set _ WRONG}] {$a} $rmap [subst $vexp]] } puts "init: proc test$i { $args } ..." } return $i } init }] puts {}; set i 0; time {foo::test[incr i]} $cnt; set _ {} </code></pre> results to the: <pre><code> init: proc test1 { {i 1} {vmap a} {rmap ::foo::a} } ... init: proc test2 { {i 2} {vmap a::a} {rmap ::foo::a::a} } ... init: proc test3 { {i 3} {vmap ::a} {rmap ::a} } ... init: proc test4 { {i 4} {vmap ::a::a} {rmap ::a::a} } ... init: proc test5 { {i 5} {vmap ::foo::a} {rmap ::foo::a} } ... init: proc test6 { {i 6} {vmap ::foo::a::a} {rmap ::foo::a::a} } ... 6 % puts {}; set i 0; time {foo::test[incr i]} $cnt; set _ {} 1: a is ::foo::a == OK == {$a eq ::foo::a } -- {"::foo::a" eq "::foo::a"} 2: a::a is ::foo::a::a == OK == {$a eq ::foo::a::a } -- {"::foo::a::a" eq "::foo::a::a"} 3: ::a is ::a == OK == {$a eq ::a } -- {"::a (of global)" eq "::a (of global)"} 4: ::a::a is ::a::a == OK == {$a eq ::a::a } -- {"::a::a" eq "::a::a"} 5: ::foo::a is ::foo::a == OK == {$a eq ::foo::a } -- {"::foo::a" eq "::foo::a"} 6: ::foo::a::a is ::foo::a::a == OK == {$a eq ::foo::a::a } -- {"::foo::a::a" eq "::foo::a::a"} </code></pre> What I'm doing wrong, resp. which point I miss here? Respectively which resolver exactly acts differently? I hold it for impossible (as long as not some own interp/namespace variable-resolver used). - login: "sebres"
- mimetype: "text/x-fossil-wiki"