lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


> function dump_table(t, prefix, seen)
>       prefix = prefix or ""
>       seen = seen or {}
>       if seen[t] then
>           print(prefix .. " is recursive")
>       else
>           seen[t] = t
>           local k,v
>           for k,v in pairs(t) do
>                 if(type(v) == "table") then
>                       dump_table(v, prefix .. k .. ":",seen)
>                 else
>                       print(prefix .. k .. "=" .. tostring(v))
>                 end
>           end
>       end
> end

This technique is used in http://www.lua.org/cgi-bin/demo?globals