On Wed, Oct 19, 2011 at 8:33 AM, Philipp Janda
<siffiejoe@gmx.net> wrote:
On 18.10.2011 05:53, Tang Daogang wrote:
Not a good idea if your strings look like numbers:
$ cat > adds.lua
local mt = getmetatable( "" )
mt.__add = function( a, b )
return a .. b
end
print( "1" + "2" )
^D
$ lua adds.lua
3
Lua tries to convert arguments of '+' to numbers and apply numeric addition *before* metamethods are involved.
That is true. I think this is lua's flaw, thanks for your mention, let me think how to treat this case.
Philipp