debug = {}

debug.indent = ""

debug.rdump = function (k, v)

   if type(v) ~= "table" then

      print(debug.indent .. tostring (k) .. " = " .. type(v) .. " " .. tostring(v))
   else

      local _indent = debug.indent;
      print (debug.indent .. tostring (k) .. " = {")
      debug.indent = debug.indent .. "  ";
      table.foreach(v, debug.rdump);
      debug.indent = _indent
      print (debug.indent .. "}")
   end
end

print_r = function (k, v)

   if (not v) then debug.rdump ("(unknown)", k)
   else debug.rdump (k, v)
   end
end
