lua-users home
lua-l archive

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


How would I go about emulating function pointers in lua?  Basically, what
I'm trying to accomplish is something like:

gCmdList = {
	cmd1 = do_cmd1(),
	cmd2 = do_cmd2(),
	...
}

gObj1 = {
	[properties]
	lCmdList = {
		cmd3 = do_cmd3(),
		cmd4 = do_cmd4(),
		...
	}
}

gObj2 = {
	[properties]
	lCmdList = {
		cmd5 = do_cmd5(),
		cmd6 = do_cmd6(),
		...
	}
}

function do_cmd1()
	block
end

function do_cmd2()
	block
end

function gObj1:do_cmd3()
	block
end

function gObj1:do_cmd4()
	block
end

function gObj2:do_cmd5()
	block
end

function gObj2:do_cmd6()
	block
end


Thanks,

--jsm