lua-users home
lua-l archive

Re: Lua registry, environment, and threads.

[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--

AltStyle によって変換されたページ (->オリジナル) /