lua-users home
lua-l archive

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


On Sat, Jan 9, 2010 at 3:08 PM, Leo Razoumov <slonik.az@gmail.com> wrote:
> 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.

Well, exactly. We always tell newbies to cache the result of compiling
expressions.

We are ending up with a catalogue of useful/essential things that
cannot not be done without setfenv.

(BTW, a safer 5.2 idom is:

local loadstring = loadstring
in {x = 1, y = 10} do fn = loadstring 'return x + y' end

Given that loadstring is potentially a nasty function in a sandbox)

steve d.