Skip to content
Tcl Source Code History Of Ticket 1587442fffffffffffffffffffffffffffffffff
Login

History Of Ticket 1587442fffffffffffffffffffffffffffffffff

Artifacts Associated With Ticket 1587442fffffffffffffffffffffffffffffffff

  1. Ticket change [497900992a] (rid 100056) by msofer on 2006-10-30 20:05:56:

    1. assignee initialized to: "msofer"
    2. cmimetype initialized to: "text/plain"
    3. comment initialized to:
      Currently 
         upvar 1 x ::a::y
      will create a variable y in namespace a, linked to the
      variable x in the caller's context.
      
      This "action at a distance" is undocumented and
      possibly confusing.  It is better IMO to force upvar to
      only create variables in the current context (namespace
      or proc call frame).
      
      Attached a patch that implements and documents this
      feature. Note that the tests var-3.7/8 test for the
      current behaviour.
      
      
    4. foundin initialized to: "None"
    5. is_private initialized to: "0"
    6. priority initialized to: "5 Medium"
    7. resolution initialized to: "None"
    8. status initialized to: "Open"
    9. submitter initialized to: "msofer"
    10. subsystem initialized to: "07. Variables"
    11. title initialized to:
      let upvar only create variables in the current context
      
    12. type initialized to: "RFE"
  2. Ticket change [32a446aa76] (rid 93645) by msofer on 2006-10-31 03:05:56:

    1. icomment:
      
      
      File Added - 200677: upvar.patch
      
      
      
    2. login: "msofer"
    3. mimetype: "text/plain"
    4. username: "msofer"
  3. Add attachment "upvar.patch" [b9f4f90668] (rid 129234) by msofer on 2006-10-31 03:05:56.

  4. Ticket change [978a1c9ebf] (rid 110454) by kaitzschu on 2006-11-03 19:10:37:

    1. icomment:
      Logged In: YES 
      user_id=966098
      
      So how does one do (centralized namespace variable templating without copying)
      
      set tcnt -1
      foreach ns {ns1 ns2 ns3} {
       for {set cnt 0} {$cnt < 5} {incr cnt} {
        foreach arn {arr lis dic} {
         upvar #0 [namespace current]::$arn[incr tcnt] ::${ns}::$arn$cnt
        }
       }
      }
      
      after this implementation when ns and cnt are variadic? Instead of upvaring these to heavens high one is supposed to
      
      namespace inscope ::$ns upvar [namespace current]::$arn$[incr tcnt] $arn$cnt
      
      or something even remotely resembling? Is this "remotely controlled action at distance" then documented (can I trust these links 
      do exist) or am I simply "doing the wrong thing"?
      
      
    2. login: "kaitzschu"
    3. mimetype: "text/plain"
    4. username: "kaitzschu"
  5. Ticket change [1abb942776] (rid 123032) by msofer on 2006-11-03 22:18:19:

    1. icomment:
      Logged In: YES 
      user_id=148712
      
      The idea is that you [namespace eval] in the namespace where
      you want your variables to be created; I would code your
      algorithm as
      
      set tcnt -1
      foreach ns {ns1 ns2 ns3} {
          set lst [list namespace upvar [namespace current]]
          for {set cnt 0} {$cnt < 5} {incr cnt} {
              foreach arn {arr lis dic} {
                  lappend lst $arn[incr tcnt] $arn$cnt
              }
          }
          namespace eval $ns $lst
      }
      
      On the other hand, your current algorithm I would also code
      somewhat differently. Note that
        upvar #0 [namespace current]::x ::a::y
      is equivalent to the faster (and IMO clearer)
        upvar 0 x ::a::y
      
      So, I would now code yours as
      
      set tcnt -1
      set lst [list upvar 0]
      foreach ns {ns1 ns2 ns3} {
          for {set cnt 0} {$cnt < 5} {incr cnt} {
              foreach arn {arr lis dic} {
                  lappend lst $arn[incr tcnt] ::${ns}::$arn$cnt
              }
          }
      }
      eval $lst
      
      
      
      
    2. login: "msofer"
    3. mimetype: "text/plain"
    4. username: "msofer"
  6. Ticket change [691fe4ed30] (rid 103194) by msofer on 2006-11-03 22:22:06:

    1. icomment:
      Logged In: YES 
      user_id=148712
      
      Forgot to mention: [namespace upvar] is in 8.5; it has
      nothing to do with this feature request really.
      
      
    2. login: "msofer"
    3. mimetype: "text/plain"
    4. username: "msofer"
  7. Ticket change [b1ec952881] (rid 98249) by dgp on 2006-11-04 02:30:50:

    1. icomment:
      Logged In: YES 
      user_id=80530
      
      I haven't had the cycles to spare
      to check this out rigorously, but
      it raises my suspicion that it will
      thoroughly break things done in the
      Tk script library.  Please check that
      over carefully before proceeding.
      
      
    2. login: "dgp"
    3. mimetype: "text/plain"
    4. username: "dgp"