lua-users home
lua-l archive

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


On 2010-01-09, steve donovan <steve.j.donovan@gmail.com> wrote:
> On Sat, Jan 9, 2010 at 1:29 PM, steve donovan <steve.j.donovan@gmail.com> wrote:
>  > debug.setfenv still works as expected in this context:
>
>
> A more idiomatic Lua 5.2 way of compiling a function-with-a-context:
>
>  > in {x = 1, y = 10, loadstring = loadstring} do fn = loadstring 'return x + y' end
>  > = fn()
>  11
>

Calling loadstring 'return x + y' hurts performance especially if used
multiple times. For me Lua's getfenv/setfenv was a killer feature very
useful in multiple passes over the same dataset in statistical data
analysis.

--Leo--