[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Praise of Lua from a game developer
- From: steve donovan <steve.j.donovan@...>
- Date: Fri, 27 Jul 2012 07:05:49 +0200
On Thu, Jul 26, 2012 at 10:21 PM, Pierre-Yves Gérardy <pygy79@gmail.com> wrote:
> Does that approach handle mutable upvalues?
Yes, but slowly, since some metamethod/debug magic is needed to set
them. For immutables, it's much easier.
local boo = 1
local M = {}
...
function M.foo() return boo end
..
OK, so to recompile M.foo we wrap it so:
local _v = ...; local boo, M = _v.boo,_v.M
function M.foo() return boo end
and pass this chunk a table extracted from the values of its current upvalues.
It can't of course acquire new upvalues without a complete
recompilation of the module. That's fast enough, true, but the issue
here is preserving module state as long as possible.
steve d.