lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


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