lua-users home
lua-l archive

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


2014-11-19 21:26 GMT+00:00 Thiago L. <fakedme@gmail.com>:
> <SoniEx2> %5.3 t=setmetatable({")", "'test'", "print("},{__call =
> function(t,...) return table.remove(t) end}) load(t)()
> <yalb> SoniEx2: sandbox:1: bad argument #1 to 'load' (function expected, got
> table); stack traceback:; [C]: in function 'load'; sandbox:1: in main chunk
>
> Can we please get a callable API? (for example, iscallable(obj), or in C,
> lua_iscallable(whatever))

You can always wrap a callable in a function, and a function is both
type-testable and always callable. So if you need a testable callable,
just wrap your object in a function. Given how easy that solution is,
you'll need more than a "please" to get that kind of feature. Where
are use cases, stats, benchmarks?