title: Function/variable scope (pass by value or reference?)
body: <p>I'm completely confused by <strong><a href="http://lua.org">Lua</a></strong>'s variable scoping and function argument passing (value or reference).</p>
  
  <p>See the code below:</p>
  
  <pre><code>local a = 9        -- since it's define local, should not have func scope
  local t = {4,6}    -- since it's define local, should not have func scope
  
  function moda(a)
    a = 10           -- creates a global var?
  end
  function modt(t)
    t[1] = 7         -- create a global var?
    t[2] = 8
  end
  
  moda(a)
  modt(t)
  print(a)  -- print 9 (function does not modify the parent variable)
  print(t[1]..t[2])  -- print 78 (some how modt is modifying the parent t var) 
  </code></pre>
  
  <p>As such, this behavior completely confuses me.</p>
  
  <ul>
  <li><p>Does this mean that table variables
  are passed to the function by
  reference and not value?</p></li>
  <li><p>How is the global variable creation
  conflicting with the already define
  local variable? </p>
  
  <ul>
  <li>Why is <code>modt</code> able to
  modify the table yet <code>moda</code> is not able
  to modify the a variable?</li>
  </ul></li>
  </ul>