In Lua, how can you print the name of the current function, like the C99 __func__ identifier?

前端 未结 7 1752
别那么骄傲
别那么骄傲 2021-02-13 03:49

Something like this:

function foo()
    print( __func__ )
   ...
end

How can it be done?

7条回答
  •  感动是毒
    2021-02-13 04:31

    Use the Debug Library. It provides a getinfo(func) function that returns a table with information about the function.

提交回复
热议问题