lua-users home
lua-l archive

Re: Function as metatable (metafunctions?)

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


2014年03月31日 19:42 GMT+02:00 Philipp Janda <siffiejoe@gmx.net>:
> Sadly we don't have `rawtostring` available in Lua, so this specific example
> is difficult, but in principle it should work ...
rawtostring = function(value)
 local mt=getmetatable(value)
 if not mt then return tostring(value) end
 debug.setmetatable(value,nil)
 local str=tostring(value)
 debug.setmetatable(value,mt)
 return str
end

AltStyle によって変換されたページ (->オリジナル) /