mlua icon indicating copy to clipboard operation
mlua copied to clipboard

A way to uniform functions with tables and userdata with `__call`

Open hack3ric opened this issue 3 years ago • 1 comments

There are many use cases where you need to treat callable objects as function, especially when writing a library.

Maybe add a {Table, AnyUserData}::into_function, since TableExt::call's implementation is just turning the table into function and then call it?

hack3ric avatar Jul 28 '22 12:07 hack3ric

I need to think about it. Not only into_function is needed, but apparenly a way to call functions/methods on arbitrary userdata. Also, into_function seems too optimistic. There are other functionality available for functions, such as dump, info, coverage that may fail on callable objects.

khvzak avatar Jul 28 '22 20:07 khvzak

This is done, by the AnyUserDataExt trait

khvzak avatar Mar 31 '23 09:03 khvzak