Import functions from a table as local functions in Lua

I want to achieve this (import function from the usage table as local values):

function blah () 
 local x = util.x
 local y = util.y
 ...
end

without the need to reference each function explicitly, for example. sort of:

function blah()
  for name,f in util do 
    ???
  end
end

Unfortunately, there is no local table in which I could set the way _G ['function_name_as_string'] could be set. Ideas?

+3
source share
2 answers

As far as I know, you cannot set local variables by name. You will need to do this explicitly.

Fyi, _L, _G, . , . - setlocal("foo", xxx), Lua .

+3

IIRC, metalua, - . , , .

+2

Source: https://habr.com/ru/post/1714962/


All Articles