lua-users home
lua-l archive

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



On 3/20/2010 10:44 PM, Mark Hamburg wrote:
See the specification for the __mul operator in the Lua spec (section 2.8).

The implementation of the * operator looks in the metatable for a __mul entry. It does not perform a message send. It does not index the object. Once it finds the entry, it passes it the two operands. In other words, it does more or less exactly this:

	local temp = bot:getLoc()
	newpt = getmetatable(temp).__mul(temp, 2)

With the exception of storing the intermediate in temp, isn't that pretty much the same as:

newpt = getmetatable(bot:getLoc()).__mul(bot:getLoc(), 2)

This works, but the * operator does not, so they are not doing quite exactly the same thing :-)

BTW, I cannot test using temp as an intermediate as shortly after I posted, my graphics card blew up, and my dev machine is now out of service until I get it fixed :-(

Thanks for your help,

Chris