lua-users home
lua-l archive

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


On 26 Dec 2013, at 20:15, Sir Pogsalot <sir.pogsalot@gmail.com> wrote:

> Currently you can only assign functions to __call, not tables or userdata with their own __call.

What is wrong with this? (Lua 5.2)

t = makecallableobject()
t2 = setmetatable({}, {__call = function(…) return t(select(2, …)) end})
t2()

The select is to throw away t2 from t's argument list - obviously in some cases you will want to keep that.

Thanks,
Kevin