Differenciate user created functions from library functions

Is there a way to differenciate user created functions from library functions in _G table ?

Thanks for your help.

I don’t think so, what are you attempting to do?

We insert the global functions into Lua (from C) as follows:

lua_pushcfunction(L, func)
lua_setglobal(L, name)

I expect this adds the name to _G as normal.

One thing you could do is add some code to the start of your left-most tab that makes a shallow copy of the _G table. I say the left most, because tabs are executed left to right. So your shallow copy would be ‘unpolluted’ by user variables. You can then filter the list by type to get all functions, etc.

@Leon_levy I am not quite sure why you would want to do that, but there is a way to distinguish functions written in Lua from functions written in C. If you call debug.getinfo() on the function, that returns a table with info about that function. In this table, there is a field ‘what’, which is “C” for low level (C) functions, and has other values for functions written in Lua. So basically, for builtins, you would look for the value “C” in that field.

Thank you Gunnar, it worked well.
Nice to have help so fast from all of you.
Leon