[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Reuse of userdata?
- From: "Adam D. Moss" <adam@...>
- Date: Sat, 10 Jan 2004 00:39:09 +0000
Ando Sonenblick wrote:
But I'm unclear on the use of the userdata finalizer. If a userdata has
a metatable with a __gc field, I know it gets called but does the GC
mechanism then still collect the userdata object after calling it?
I'd ideally like it to NOT collect the userdata object so that I can,
say, stash it in some table (so it won't be collected) and then when I
need to use a userdata, I can get the stashed one and reset its value,
instead of having to allocate a new one.
If you create a new reference to the object within the __gc
callback then the object will safely survive the GC.
--Adam
--
Adam D. Moss . ,,^^ adam@gimp.org http://www.foxbox.org/ co:3