lua-users home
lua-l archive

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


Gang,

Thanks to all for help with my lua question about auto initing nil values in a table to zero...

A couple replies utilize the __call metamethod. I'm not terribly familiar with this one and the manual only has this to say about it:

"call": called when Lua calls a value.
<x-tad-bigger> function function_event (func, ...)
if type(func) == "function" then
return func(unpack(arg)) -- primitive call
else
local h = metatable(func).__call
if h then
return h(func, unpack(arg))
else
error("...")
end
end
end
</x-tad-bigger>


Can anyone give me more info on this? What exactly does it mean when "Lua calls a value"?

Can I use this to distinguish between obj:Method() and obj.method?

Thanks for any insight...

Ando
-----------------------
Ando Sonenblick
SpriTec Software
www.spritec.com