lua-users home
lua-l archive

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

This is done in the last part of my code. But this is not the point.
the point is:
On lua51 I managed to get all the keywords (global definitions of functions
and tables and the functions in this tables) from some lua files which also
used require on other lua files.

and the key functions are loadinEnv and newrequire

----- Original Message ----- From: "Dirk Laurie" <>
To: "Lua mailing list" <>
Sent: Monday, April 08, 2013 2:21 PM
Subject: Re: getting keywords in lua5.2

2013/4/8 Victor Bombi <>:

It does not work, environment is missing the definitions in the required
I think that it was too complicated in lua51 version. I wonder if there is a
better way in lua 52

function add_functions_in(source,target,tag)
-- adds the functions in table "source" to table "target" with given tag
-- returns a list of all tables in "source"
  local t={}
  for k,v in pairs(source) do
     if type(v)=='function' then target[tag..'.'..k]=v
     elseif type(v)=='table' then t[k]=v
  return t

local done = {}
function catalog(source,target,tag)
-- recursively adds the functions in table "source" and all functions
-- accessible via "source" to table "target"
  local new=add_functions_in(source,target,tag)
  for k,v in pairs(new) do if not done[v] then
  end end
  return target

for k,v in pairs(cat) do print(k) end

------------ prints out this: ------------