lua-users home
lua-l archive

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


On Thu, Jul 26, 2012 at 12:25 PM, steve donovan
<steve.j.donovan@gmail.com> wrote:
> The issue of incremental compilation is important and I suspect it is
> solvable, using an insight of Peter Cawley's: when you recompile a
> function, you recompile that function within an artificial chunk that
> mimmicks the original upvalues.  Got some test code working a while
> back and then lost it.

Did you mean dynamic compilation? I see this problem as manageable if
you're okay with not sharing the upvalues:

for i = 1, n do
  <code>
  local f = load("local i = ...; return function (...)"..text.." end")
  f = f(i)
  <code>
end

You can also go to the trouble of using the debug library to
automatically create and set the locals. If you're using Lua 5.2, you
can of course join the upvalues as well.

-- 
- Patrick Donnelly