[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Explanation needed for setfenv replacement for Lua 5.2
- From: steve donovan <steve.j.donovan@...>
- Date: Fri, 6 May 2011 15:23:13 +0200
On Thu, May 5, 2011 at 10:53 PM, E. Toernig <froese@gmx.de> wrote:
> for _ENV in Interpreter do
> AddItem "hello!"
> AddItem(AN_UPVALUE)
> AddItem "Hope You Enjoy!"
>
> PrintResult() --> hello! This is a silly DSL! Hope You Enjoy!
> end
That is a very cute piece of code - bordering on abuse, maybe, but it
looks good!
Let me see if I get it:
function env(tbl)
return function(_,second_iteration)
if second_iteration then return nil end
return tbl
end
end
for _ENV in env {print=print,A=1,B=2} do
print(A,B)
end
The in statement reappears ...
steve d.