lua-users home
lua-l archive

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


Laurent Faillie wrote:
[...]
> Because I don't want to pollute my global area : they are used in
> plug-ins for a larger system and I would like to avoid any interference
> b/w each plug-in.

You can always do something like this:

local function func1() ... end
local function func2() ... end
local function func3() ... end

local functable = {
	["func1"] = func1,
	["func2"] = func2,
	["func3"] = func3,
}

local function call_by_name(s)
	local f = functable[s]
	f()
end

-- 
┌─── dg@cowlark.com ───── http://www.cowlark.com ─────
│
│ 𝕻𝖍'𝖓𝖌𝖑𝖚𝖎 𝖒𝖌𝖑𝖜'𝖓𝖆𝖋𝖍 𝕮𝖙𝖍𝖚𝖑𝖍𝖚 𝕽'𝖑𝖞𝖊𝖍
𝖜𝖌𝖆𝖍'𝖓𝖆𝖌𝖑 𝖋𝖍𝖙𝖆𝖌𝖓.
│

Attachment: signature.asc
Description: OpenPGP digital signature