title: Make __call metamethod as iterator
body: <p>I'm trying to emulate execution of certain functions from scripts of other app. That app have Lua library which contains function <code>list()</code>, it returns table where key is string UUID and value just string, like <code>local tbl = { "0000..-0000-..." = "someString", etc... }</code>. That table can be iterated in for loop, like</p>
  
  <pre class="lang-lua prettyprint-override"><code>local lib = require("someLibrary.lua");
  
  for key, value in lib.list() do
      -- do something with keys and values, like print
  end
  
  -- or it can be used like this
  
  local tbl = lib.list();
  for key, value in tbl do -- tbl works as pairs(tbl) and works exactly how code on top
      -- do something with keys and values, like print
  end
  </code></pre>
  
  <p>So the question, how do I implement __call metamethod to work as pairs() or next() etc.?</p>
  
  <p>Thanks</p>