[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Suggestion for Lua 5.3: assign callables to __call (not only functions), also add rawcall()
- From: Kevin Martin <kev82@...>
- Date: Fri, 27 Dec 2013 18:58:08 +0000
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