How can I prevent my table Lua callable as an argument to __call?


Say I have the following code:

local t = {};
setmetatable(t, {__call=print});
t(3, 5, 7)

Instead of printing:

3    5    7

it prints:

table: 0x9357020    3   5   7

The id of the table is that of t.

How can I make it behave as though I called print directly?

You can't; the function specified by __call always gets passed the item that was called.

What you could do, though, is create a wrapper function that just discards the first argument and calls the function you originally wanted to call with just the arguments after the first, and set that wrapper function as the __call value.