title: Is there a way to iterate over a userdata, like pairs and ipairs do with a table?
body: <p>Is there a function to iterate over the entries in a userdata value? I'm trying to list every field and its value in some userdata variable, just like <code>pairs</code> would do:</p>
  
  <pre><code>local function list_entries ( obj )
      for k, v in pairs ( obj ) do
          print ( k .. ": " .. tostring ( v ) )
      end
  end
  </code></pre>
  
  <p><code>pairs</code> doesn't work for userdata, so is there a solution to this?</p>