Suggestion to garbage collection in Lua 3.2

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Suggestion to garbage collection in Lua 3.2

Erik Hougaard
To make Lua even more usable - I'm suggestion this addon to the GC
system:

When creating a user tag (lua_newtag) supply a function (or NULL) with
the tag and then in luaS_free call the function with the pointer to the
userdata. We can then program a C function that will free/close
resources.

In that way we can ensure that the garbage collection will/can clean
whatever memory we have allocated, files we have opened (the iolib could
also use this) resources allocated etc. without having to make sure that
our users remember to call closefile/closedatabase/disconnectserver or
whatever functions we might have in our system.

Any comments?

Erik Hougaard

Reply | Threaded
Open this post in threaded view
|

Re: Suggestion to garbage collection in Lua 3.2

David Jeske-2
On Mon, Oct 26, 1998 at 12:49:10PM -0200, Erik Hougaard wrote:
> To make Lua even more usable - I'm suggestion this addon to the GC
> system:
> 
> When creating a user tag (lua_newtag) supply a function (or NULL) with
> the tag and then in luaS_free call the function with the pointer to the
> userdata. We can then program a C function that will free/close
> resources.
> 
> In that way we can ensure that the garbage collection will/can clean
> whatever memory we have allocated, files we have opened (the iolib could
> also use this) resources allocated etc. without having to make sure that
> our users remember to call closefile/closedatabase/disconnectserver or
> whatever functions we might have in our system.

Uhm, you can already do that. Set a function for the "gc" tag method.


-- 
David Jeske (N9LCA) + http://www.chat.net/~jeske/ + [hidden email]