lua-users home
lua-l archive

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


> However one unavoidable case is when it's necessary to
> free some system resource (other than memory) claimed at object
> construction.

You can always associtate a userdata with the resource, and use its
GC tag method. For instance, you can put the userdata as a field of
a table, so that its GC tag method will be called when the table is
collected.

> It would be nice if Lua had support for weak references.

The C API does support weak references. It is not difficult to export
this facility to Lua.

-- Roberto