title: Understanding the use of Tcl namespace variable
body: <p>I have a namespace variable which is defined as below: </p>
  
  <pre><code>   namespace eval ::SMB::{
        variable SmbInfo
        ------
        ------
  
      proc ::SMB::SmbCreate {name dutport} {
          variable SmbInfo
          global DutPorts DutPort_2 DutPorts_3 smb
  
          ------
          ------
          if{"" != [info command SMB::$name]} {
             return -code error "command name \"$name\" already exists"
          }
          set SmbInfo($name -DutPort) $dutport
  </code></pre>
  
  <p>I am new to Tcl and trying to understand the above piece of code. Few questions, please correct me if I am wrong at any point:</p>
  
  <ol>
  <li><p>The variable SmbInfo defined on top in namespace is getting overridden by the one declared in the procedure SmbCreate. I am unable to figure out what is the objective of the line: </p>
  
  <pre><code>     set SmbInfo($name -DutPort) $dutport
  </code></pre>
  
  <p>I can see that 'DutPorts' is defined as global but I could not find 'DutPort'. I have not executed the code yet. Could it be an error? </p></li>
  <li><p>Is ($name - DutPort) creating an array index for the variable SmbInfo and the value of $dutport is being set to that particular array variable?</p></li>
  <li><p>I have similar code structures in the file like below</p>
  
  <pre><code>set SmbInfo($name - SmbSetDmac) [BuildMac1 $SmbInfo($from_name-DutPort)]
  </code></pre>
  
  <p>Where BuildMac1 is a procedure. A bit explanation of the above code might also make the thing clear.</p></li>
  </ol>
  
  <p>If anything I missed to post in the question, kindly point me, I will edit my question.
  Thanks in advance.</p>