[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Getting the address of a table with a __tostring
- From: Geoff Leyland <geoff_leyland@...>
- Date: Mon, 19 Oct 2009 11:35:12 +1300
Hi,
Has anyone got a better idea for getting the address of a table with a
__tostring in its metatable than this?
> a = setmetatable({}, { __tostring = function() return "pretty but
no address" end})
> print(a)
pretty but no address
> function rawtostring(t) local mt = getmetatable(t) setmetatable(t,
nil) local r = tostring(t) setmetatable(t, mt) return r end
> print(a, rawtostring(a), a)
pretty but no address table: 0x115150 pretty but no address
It works, but it's a bit mucky.
Cheers,
Geoff