title: How come a proc local variable interferes with global variable
body: <p>I am using TCL 8.6.</p>
  
  <p>Here is the code:</p>
  
  <pre><code>proc unpack_list {list1  list2} {
      set i 0
      foreach e $list2 {
          puts "globals=[info globals $e]"
          global $e
          set $e [lindex $list1 $i] 
          incr i
      }
  }
  
  set l1 [list 10 20 30 40]
  set l2 [list a b c e]
  unpack_list $l1 $l2
  puts $a
  puts $b
  puts $c
  puts $e
  puts [info globals ]
  </code></pre>
  
  <p>Running the code fails:</p>
  
  <pre><code>globals=
  globals=
  globals=
  globals=
  variable "e" already exists
      while executing
  "global $e"
      (procedure "unpack_list" line 5)
      invoked from within
  "unpack_list $l1 $l2"
      (file "tmp/1.tcl" line 13)
  </code></pre>
  
  <p>The problem lies at this line:</p>
  
  <pre><code>set l2 [list a b c e]
  </code></pre>
  
  <p>If I change "e" to "ee", the script runs fine:</p>
  
  <pre><code>globals=
  globals=
  globals=
  globals=
  10
  20
  30
  40
  tcl_rcFileName tcl_version argv0 argv tcl_interactive a ee b c auto_path env tcl_pkgPath tcl_patchLevel l1 argc l2 tcl_library tcl_platform
  </code></pre>
  
  <p>My question is: The variable "e" inside the proc does not exist in global namespace, how come it interferes with the global variable "e"?</p>