lua-users home
lua-l archive

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


On Tue, Jul 23, 2013 at 12:32 PM, Rena <hyperhacker@gmail.com> wrote:

I'd long wished for isindexable() and iscallable(), so that tables, functions, and userdata with the appropriate metamethods can be interchanged. Right now even if I have __call and __index on a userdata, many libraries won't accept it because they check the type explicitly.

I do something like this in pl.tablex

https://github.com/stevedonovan/Penlight/blob/master/lua/pl/tablex.lua#L32

However, indexable checks aren't exported; is_callable is exported, as well as the inevitable extended type function ;)

https://github.com/stevedonovan/Penlight/blob/master/lua/pl/utils.lua#L265