[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Recipe: setfenv with Lua 5.2.0 work3
- From: Roberto Ierusalimschy <roberto@...>
- Date: Wed, 16 Jun 2010 08:46:00 -0300
> I thought upvaluejoin can only join upvalues. How can it be used to
> break the link?
function breaklink (f, upidx)
local a
local function dummy () return a end
debug.upvaluejoin(f, upidx, dummy, 1)
end
The call 'breaklink(f,n)' will make the n-th upvalue from 'f' point to
a fresh upvalue (refering to variable 'a'), not shared with any other
function.
-- Roberto