title: Local functions calling each other
body: <p>I have two functions that occasionally call each other, and they are local to a module that uses them to build another function. The module is somewhat similar to this piece of code:</p>
  
  <pre><code>local function iseven(n)
      if n == 1 then
          return false
      else
          return isodd(n - 1)
      end
  end
  
  local function isodd(n)
      if n == 1 then
          return true
      else
          return iseven(n - 1)
      end
  end
  
  local evenOrOdd = function(n)
      return iseven(n) and "Even" or "Odd"
  end
  
  return evenOrOdd
  </code></pre>
  
  <p>The problem is, when calling <code>evenOrOdd</code> from another file I get the error <code>attempt to call global 'isodd' (a nil value)</code>.</p>
  
  <p>I noticed that this doesn't happen if I set <code>iseven</code> to global, but I would like to keep them local to my module.</p>
  
  <p>I even tried putting a dummy function declaration (<code>local function isodd() end</code>) before the line where <code>iseven</code> is declared. I also tried inserting just <code>local isodd</code> in the place of the dummy function declaration, but in both ways it doesn't work and I get different kind of errors.</p>
  
  <p>I know this is because Lua has closures and when <code>iseven</code> is declared it catches the actual value of <code>isodd</code>, which is either <code>nil</code> or the dummy function, and modifying it after doesn't count, but is there a way to bypass this?</p>