Something like this:
function foo()
print( __func__ )
...
end
How can it be done?
You can't. In lua, functions are first class variables. So they don't have names.
Lua print in Lua programming language is an inbuilt function that is used for printing the required statement in the console.
This means that all values can be stored in variables, passed as arguments to other functions, and returned as results. There are eight basic types in Lua: nil, boolean, number, string, function, userdata, thread, and table.
#!/usr/bin/lua
local function myFunc()
print(debug.getinfo(1, "n").name);
end
myFunc()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With