[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: How to set the environment of a function
- From: "Sherry Zhang" <yuleopen@...>
- Date: Sun, 8 Jul 2007 07:11:26 +0800
hi,
Now I have a program like
a={}
a["foo"]=function() bar() end
a["bar"]=function () print("Hello") end
function p(t) foo() end
p(a)
when running p(a) , I want to get the "Hello" output.
and I want to know two easy way to do that.
( I do not ways like for k, v in pairs(t) do ... end)
1 how to set it outside the function and leave the function unmodified?
2 how to set it inside the function?
thanks in advance!