[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Garbage collection durint pcall.
- From: Roberto Ierusalimschy <roberto@...>
- Date: Thu, 30 May 2019 12:57:16 -0300
> > I believe that many programmers stumble upon this while learning Lua.
>
> Well, it is a very strange thing to hit, you need to do some weird
> things, starting by clearing the "local" which holds it inside the
> function. I just got to it because I was being defensive.
It is weirded than that. You also need some alternative way to access
the value that is being collected. (In your case, you didn't have
access to the value itself, but to some C structure being closed by
__gc. Another option, as already pointed out, is through a weak table.)
That doesn't seem common for someone learning Lua.
-- Roberto