lua-users home
lua-l archive

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


On Oct 30, 2013, at 5:06 PM, Paige DePol <lual@serfnet.org> wrote:

> 
> I patched the parser and added a 'global' keyword for the explicit declaration of global variables, though instead of storing my table in _G I stored it in the registry.
> 
> -Paige

Given that strict had created the __declared table inside _G I was able to make a function to list all globals like so:

function listglobals()
	local t = getmetatable(_G)
	for i,_ in pairs(t.__declared) do
		local ty = type(_G[i])
		local sz = 0
		if ty == 'table' then sz = #_G[i] end
		printf('%20s,	%10s,	%4d',i, ty, sz)
	end
end

Its remarkable how easy it is to do things like this in Lua.



Jose de la Torre-Bueno, Ph.D.
Empowered Energy Solutions Inc.
Intellectual Property & Technology Management
T (619) 977-0553
F (760) 295-7119
jtorrebueno@cox.net