lua-users home
lua-l archive

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


I noticed strange behavior with debug.getinfo(1).name, in particular,
it doesn't get set if the current function f (for which you want to
get the name for) was called with return f() instead of just f(). Eg.:

function f()
	local t,kt={},{}
	for k,v in pairs(debug.getinfo(1)) do t[k]=v end
	for k in pairs(t) do table.insert(kt,k) end
	table.sort(kt)
	for _,k in ipairs(kt) do print(k,t[k]) end
end

function g() f() end
function h() return f() end

g()
print('-------')
h()


The above gets the name of f if called from g() but not from h() -
happens with both 5.1 and 5.2; luajit2 even finds the name to be 'h'
in the second case which is even more misleading.

So how can one implement a simple argcheck'ing function with this mess? :)