[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Lua strictlessness
- From: Tangent 128 <tangent128@...>
- Date: Fri, 23 Aug 2013 20:59:02 -0400
On 08/23/2013 05:40 AM, Leo Razoumov wrote:
> No, garbage collector will collect the t
Actually, a quick experiment:
> w = setmetatable({}, {__mode="kv"})
> function cg()
> collectgarbage()
> for k,v in pairs(w) do
> print(k,v)
> end
> print"---"
> end
> function t()
> local a = {}
> w[1] = a
> cg() cg()
>
> local a = 2
> cg() cg()
> end
>
> cg()
> t()
> cg()
shows that the local continues to prevent garbage collection as long as
it's on the stack (that is, until t() returns), even if it's lexically
shadowed.
~Joseph Wallace